Commit Graph
226 Commits
Author SHA1 Message Date
Dean b7865bbb6b Merge pull request #8344 from Retr0G28/fix/socketpair-getpeername-enotconn
fix(libkernel): return ENOTCONN from getpeername once a socketpair peer closed
2026-10-25 13:28:30 +13:00
Dean 761cb46f84 Merge pull request #10350 from orezraey/fix/libkernel-socket-receive-flags-measured-ps5
fix(libkernel): keep the TCP flag and IP receive options a PS5 accepts
2026-10-25 12:44:40 +13:00
Retr0 3af8e6d040 Merge remote-tracking branch 'origin/main' into fix/socketpair-getpeername-enotconn
# Conflicts:
#	core/libs/tests/GuestSocketPair.cpp
2026-10-25 02:23:58 +03:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean 30be9b428b Merge pull request #10331 from orezraey/fix/libkernel-multicast-membership-measured-ps5
fix(libkernel): join and leave multicast groups as measured on a PS5
2026-10-25 08:03:16 +13:00
orezraeyandClaude Opus 5.5 7c04bd3a43 Merge fix/libkernel-multicast-membership-measured-ps5 into fix/libkernel-socket-receive-flags-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 14:20:50 -03:00
orezraeyandClaude Opus 5.5 c7b39854eb Merge main into fix/libkernel-socket-flags-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 13:57:57 -03:00
Dean dc9f1ef656 Merge pull request #10327 from orezraey/fix/libkernel-tcp-options-measured-ps5
fix(libkernel): keep TCP_MAXSEG and the TCP keepalive options as measured on a PS5
2026-10-25 05:52:56 +13:00
orezraeyandClaude Opus 5.5 a328020e95 Merge main into fix/libkernel-socket-receive-flags-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 12:24:32 -03:00
Dean 2393e2e773 Merge pull request #10320 from orezraey/fix/libkernel-ip-options-measured-ps5
fix(libkernel): keep IP_TTL, IP_TOS and the multicast options as measured on a PS5
2026-10-25 04:18:17 +13:00
Retr0 8f66466e75 Merge remote-tracking branch 'origin/main' into fix/socketpair-getpeername-enotconn 2026-10-24 16:09:19 +03:00
orezraeyandClaude Opus 5.5 d9d84b5912 fix(libkernel): drop a multicast group through INADDR_ANY on any interface
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 10:01:20 -03:00
orezraeyandClaude Opus 5.5 8d28c15ea4 Merge fix/libkernel-socket-flags-measured-ps5 into fix/libkernel-multicast-membership-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 09:57:22 -03:00
orezraeyandClaude Opus 5.5 2f443f3b88 Merge fix/libkernel-tcp-options-measured-ps5 into fix/libkernel-socket-flags-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 09:56:35 -03:00
orezraeyandClaude Opus 5.5 d360078c6a Merge fix/libkernel-ip-options-measured-ps5 into fix/libkernel-tcp-options-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 09:56:27 -03:00
orezraeyandClaude Opus 5.5 55473fb673 fix(libkernel): keep the low byte of an int IP_MULTICAST_LOOP
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 09:55:58 -03:00
Adrià 887a9640b4 Merge pull request #7605 from HQasper/fix/poll-kqueues
fix(libkernel): poll kqueues as kqueue_poll answers
2026-10-24 12:32:33 +02:00
Dean efe844c653 Merge pull request #10308 from orezraey/fix/libkernel-socket-receive-measured-ps5
fix(libkernel): answer zero-length datagram receives and recvmsg flags as measured on a PS5
2026-10-24 20:46:44 +13:00
Dean 83a25ceb71 Merge pull request #9105 from Retr0G28/fix/connect-port0-connected-dgram
fix(libkernel): disconnect a connected datagram socket on connect to port 0
2026-10-24 16:54:25 +13:00
Dean 6fc058f5cf Merge pull request #10302 from orezraey/fix/libkernel-socket-buffers-measured-ps5
fix(libkernel): keep socket buffer sizes and SO_NBIO as measured on a PS5
2026-10-24 15:25:05 +13:00
Dean d8b73e3644 Merge pull request #9273 from DavidSamir/feat/libkernel-sys-pselect
feat(libkernel): implement pselect over select
2026-10-24 12:53:12 +13:00
orezraeyandClaude Opus 5.5 9402457fb7 Merge fix/libkernel-multicast-membership-measured-ps5 into fix/libkernel-socket-receive-flags-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 20:50:51 -03:00
orezraeyandClaude Opus 5.5 4dc6530ee0 fix(libkernel): refuse an ip_mreqn with a non-zero address and require the multicast host checks
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 17:45:18 -03:00
Dean 7956a166c7 Merge pull request #9108 from Retr0G28/fix/socket-address-length-exact
fix(libkernel): reject socket addresses longer than sockaddr_in or sockaddr_in6 with EINVAL
2026-10-24 09:12:39 +13:00
orezraeyandClaude Opus 5.5 dd27146c27 fix(libkernel): keep the TCP flag and IP receive options a PS5 accepts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 15:45:11 -03:00
orezraeyandClaude Opus 5.5 062dc00385 fix(libkernel): join and leave multicast groups as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 15:38:52 -03:00
orezraeyandClaude Opus 5.5 802bcc8d61 fix(libkernel): share a port between SO_REUSEPORT sockets on the host
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 15:38:45 -03:00
orezraeyandClaude Opus 5.5 122541c7a8 fix(libkernel): keep the SOL_SOCKET flags a PS5 accepts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 15:20:17 -03:00
orezraeyandClaude Opus 5.5 29f717c607 fix(libkernel): keep TCP_MAXSEG and the TCP keepalive options as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 15:20:16 -03:00
orezraeyandClaude Opus 5.5 b776394b4f fix(libkernel): keep IP_TTL, IP_TOS and the multicast options as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 15:20:03 -03:00
orezraeyandClaude Opus 5.5 d8d03c2839 fix(libkernel): give the host the requested socket buffer and test the inherited sizes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 15:16:09 -03:00
orezraeyandClaude Opus 5.5 9afaeff204 fix(libkernel): answer a zero-length recvmsg on an empty datagram socket
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 15:14:09 -03:00
orezraeyandClaude Opus 5.5 a537c33096 fix(libkernel): answer zero-length datagram receives and recvmsg flags as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 14:09:47 -03:00
orezraeyandClaude Opus 5.5 f334c156e1 fix(libkernel): keep socket buffer sizes and SO_NBIO as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 13:49:03 -03:00
Dean Galvin 2f741e737f Merge main into feat/libkernel-underscore-socket-signal-entries 2026-10-23 22:00:32 +13:00
Dean c9edaff579 Merge pull request #9104 from Retr0G28/fix/sendfile-enotsock
fix(libkernel): return ENOTSOCK from sendfile on a descriptor that is not a socket
2026-10-23 19:25:35 +13:00
Retr0 0ca2e0b4e7 fix(libkernel): return ENOTCONN from getpeername once a socketpair peer closed
getpeername on a socketpair end returned the unnamed AF_UNIX address
even after the other end was closed. In FreeBSD 11, closing an end runs
uipc_detach, whose unp_disconnect and unp_drop clear SS_ISCONNECTED on
both stream and datagram ends, and kern_getpeername then fails with
ENOTCONN. Each end now keeps a weak reference to its peer's socket,
which expires when the peer's last descriptor, duplicates included, is
closed. shutdown leaves the ends connected, as soshutdown does.
2026-10-23 08:21:09 +03:00
HQasperandClaude Opus 5.5 8fd72f02c5 fix(libkernel): poll kqueues as kqueue_poll answers
A kqueue descriptor is ready for POLLIN and POLLRDNORM while one of its
events is triggered and for no other event, as FreeBSD's kqueue_poll
answers; poll threw for it on both hosts. A kqueue cannot be waited on,
so while one is polled poll checks it every millisecond and waits on the
other descriptors in slices of 1 ms. This is the loop Windows already
used for pipes, which Linux now shares.

A kqueue closed during the wait reports POLLNVAL, and one whose number
was reused is polled again with the rest of the timeout, as FreeBSD's
pollrescan looks the descriptor up again.

Depends on #7248.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 18:13:27 +00:00
xXPBSXxandClaude Sonnet 5.5 ff2b4ba4cc fix(libkernel): report EPIPE for a stream send on a connection the peer closed on Windows
sosend_generic fails a send on a socket that can send no more with EPIPE
before it looks at so_error. Winsock reports the same send as WSAECONNABORTED
or WSAECONNRESET, which reached the guest as ECONNABORTED or ECONNRESET.
A stream send now maps both to EPIPE. The send-after-close checks of
guest_tcp, guest_socket_read_write and guest_socket_pair run on Windows too.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-22 19:09:29 +02:00
Retr0 be4fd86249 fix(libkernel): disconnect a connected datagram socket on connect to port 0
FreeBSD 11.4's soconnectat() (sys/kern/uipc_socket.c) disconnects a
connected socket of a protocol without PR_CONNREQUIRED before it calls
pru_connect. udp_disconnect() and udp6_disconnect() drop the peer and
reset the local address, then in_pcbconnect_setup() and in6_pcbladdr()
fail port 0 with EADDRNOTAVAIL, so the socket is left unconnected.
connect to port 0 on a connected datagram socket now dissolves the
association through the AF_UNSPEC disconnect path before failing with 49,
where it kept the old peer. Stream sockets keep EISCONN.
2026-10-22 20:00:13 +03:00
Adrià 8499ea52e5 Merge pull request #8499 from xXPBSXx/fix/sendto-port-zero
fix(libkernel): fail sendto to port 0 from an unbound IPv4 datagram socket with EADDRNOTAVAIL
2026-10-22 17:54:00 +02:00
Adrià 093149c5bd Merge pull request #8483 from xXPBSXx/fix/poll-peer-close-pollin
fix(libkernel): report a stream whose peer closed as readable in poll on Windows
2026-10-22 17:44:27 +02:00
David 375b53d918 refactor(libkernel): move pselect into libkernel
The PS5 3.20 export lists have pselect in libkernel as well as
libkernel_sys, and on Windows a libkernel import never reaches
libkernel_sys. The implementation moves unchanged to
libkernel/Socket/src/Pselect.cpp, beside select.
2026-10-21 22:30:43 +01:00
Adrià eaff87674c Merge pull request #8492 from xXPBSXx/fix/recv-after-shutdown-and-empty
fix(libkernel): answer a receive after SHUT_RD or with no buffer without the host
2026-10-21 20:39:37 +02:00
Adrià 0b117a8bfc Merge pull request #8392 from xXPBSXx/fix/socket-argument-order-fb
fix(libkernel): check socket address arguments before the descriptor
2026-10-21 20:05:37 +02:00
xXPBSXxandClaude Sonnet 5.5 c02a5d8034 fix(libkernel): keep the receive-after-SHUT_RD answer on Windows only
On Linux the host keeps data that was buffered before shutdown(SHUT_RD) and
guest_socket_pair expects to read it, so the shortcut that answers 0 for any
receive after SHUT_RD broke that test there. Limit the shortcut to Windows,
where the host cannot answer it, and run the post-shutdown receives of
guest_tcp on Windows only.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 20:01:18 +02:00
xXPBSXxandClaude Sonnet 5.5 ba8b881fa6 fix(libkernel): answer a receive after SHUT_RD or with no buffer without the host
soreceive_generic returns 0 for a socket whose receive side is shut and for a
zero-length receive on a connected stream socket (ENOTCONN when it is not
connected), without waiting. Winsock fails the first with WSAESHUTDOWN, which
reached the guest as EPIPE, and blocks the second until data arrives. recv and
recvfrom now answer both themselves.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 20:01:18 +02:00
Adrià 606297f34f Merge pull request #8474 from xXPBSXx/fix/recv-msg-waitall
feat(libkernel): accept MSG_WAITALL in recv, recvfrom and recvmsg on a stream socket
2026-10-21 20:00:45 +02:00
NikoandClaude Opus 5.5 0ac2b0bc6f feat(libkernel): export the underscore entry points of the socket, directory and signal calls
The PS5 libkernel exports _accept, _bind, _connect, _getdirentries,
_getpeername, _getsockname, _getsockopt, _listen, _recvfrom, _recvmsg,
_sendmsg, _sendto, _setsockopt, _sigaction and _sigsuspend (PS5 3.20
export list, DNNDHH/PS5-3.20_Libs b2a77c0 libkernel.c), and main
exports none of them, so a title importing one fails at startup. Each
now forwards to the export without the underscore, as _close, _ioctl
and _nanosleep already do.

In FreeBSD 11.4 (8c639945a4) these are libc's plain system call
entries: lib/libc/amd64/SYS.h makes bind, getdirentries, getpeername,
getsockname, getsockopt, listen and setsockopt one stub under both
names, and lib/libc/sys/Makefile.inc gives accept, connect, recvfrom,
recvmsg, sendmsg, sendto, sigaction and sigsuspend a separate public
name that goes through libthr's interposing table, which adds the
cancellation points and the sigaction wrapper. The exports without the
underscore have no libthr layer here, so forwarding gives the system
call. docs/dev/debt/libkernel.md records what stays unverified: the
console is not measured, _sigaction shares the handler table of
sigaction, and a null set throws in _sigsuspend as in sigsuspend,
where FreeBSD's system call returns EFAULT.

guest_underscore_entries calls every new export: a loopback TCP
connection, UDP datagrams with scatter, truncation and sender
addresses, a directory listing compared with getdirentries, a SIGTERM
handler set by _sigaction, and a pending SIGUSR1 that _sigsuspend
delivers before returning EINTR with the mask restored. It checks the
errors they pass on (EBADF, EINVAL, EFAULT, ENOPROTOOPT, EOPNOTSUPP)
and that outputs stay untouched on failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 17:02:54 +02:00
Retr0 f2bc1195f8 fix(libkernel): reject socket addresses longer than sockaddr_in or sockaddr_in6 with EINVAL
FreeBSD 11.4 getsockaddr sets sa_len to the length argument, and
tcp_usr_bind, tcp_usr_connect, in_pcbbind_setup, in_pcbconnect_setup,
in6_pcbbind and in6_pcbladdr answer EINVAL when it is not the size of
the socket family's address. udp6_bind and udp6_connect pass an
IPv4-mapped address to the IPv4 code without that check when
IPV6_V6ONLY is clear, and udp6_send always checks it. bind and connect
on AF_INET and AF_INET6 sockets, and sendto on AF_INET6 datagram
sockets, now fail a longer address with EINVAL.
2026-10-21 15:31:15 +03:00