Commit Graph
384 Commits
Author SHA1 Message Date
Adrià 30a863d12d Merge pull request #15135 from MarrasFederico/fix/libkernel-stream-send-enotconn
fix(libkernel): fail a send on a never-connected stream socket with ENOTCONN
2026-11-07 01:58:28 +01:00
Dean c168e146f6 Merge pull request #16081 from Opensource55/fix/socketpair-close-semantics
fix(libkernel): answer EPIPE and ECONNRESET after a socketpair peer closes
2026-11-07 09:24:09 +13:00
orezraeyandClaude Opus 5.5 36814cbbe0 Merge main into fix/libkernel-ioctl-empty-request-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 14:59:00 -03:00
Opensource55 9859dada50 fix(libkernel): answer EPIPE and ECONNRESET after a socketpair peer closes
On Windows a pair is a loopback stream or two connected datagram sockets
rather than the console's local pair. After the peer closes, the first
stream send reaches a socket the host still accepts and succeeds, where
the console fails it with EPIPE, and an empty datagram receive waits on a
socket the host never signals, where the console fails it with
ECONNRESET; a datagram queued before the close is still delivered first.
Both answers now come from the pair's lost peer before the host is
waited on. Measured on a PS5 (13.60 and 11.60): send EPIPE (32) and
receive ECONNRESET (54).

The receive side asks the socket whether a datagram is queued rather than
whether bytes are queued, because a datagram sent with no payload still
has to be delivered: ioctlsocket answers 1 for one on this host, and
select answers readable, while a byte count of the socket as a whole
would answer 0 on a host that counts payload only. The Windows case now
sends an empty datagram before the close and expects it, then 54.
2026-11-06 23:28:36 +08:00
Dean b077c1b3a0 Merge pull request #15890 from Retr0G28/fix/ioctl-scenet-socket
fix(libkernel): pass ioctl on a sceNetSocket socket to libSceNet
2026-11-06 12:17:31 +13:00
Dean ab9c66406f Merge pull request #14846 from JJenkx/windows/libkernel-poll-socket-close
fix(libkernel): notice a socket closed during poll or select
2026-11-06 12:16:30 +13:00
Evrim Cicek 11f2ffcc40 fix(libkernel): end a blocked receive on Windows when its socket is shut for reading 2026-11-05 17:48:43 +03:00
orezraeyandClaude Opus 5.5 2e5675adfa Merge main into fix/libkernel-ioctl-empty-request-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 09:23:22 -03:00
Dean 9c267bcb55 Merge pull request #12646 from slopgobblercobbler/fix/libkernel-socket-ioctl-efault
fix(libkernel): return EFAULT from socket ioctl for invalid memory pointers
2026-11-06 00:05:12 +13:00
JJenkx c5675c432b Merge remote-tracking branch 'origin/main' into windows/libkernel-poll-socket-close
# Conflicts:
#	core/libs/prx/libkernel/Socket/src/Udp.cpp
#	core/libs/tests/GuestPoll.cpp
2026-11-05 00:18:31 -05:00
Dean 1e24993fa3 Merge pull request #11223 from Ragbie/fix/poll-after-shut-rd
fix(libkernel): report a socket shut for reading in poll and select and wake their waiters
2026-11-05 17:28:28 +13:00
Retr0 69470e7075 fix(libkernel): pass ioctl on a sceNetSocket socket to libSceNet 2026-11-05 00:11:22 +02:00
ntamas94 58e537db01 fix(libSceNet): refresh socket listing on SockInfoSource 2026-11-03 21:45:18 +01:00
Federico Marras b83067a484 fix(libkernel): judge a stream socket received in a message by its host peer 2026-11-03 20:02:00 +01:00
Dean a74a4c370c Merge pull request #14310 from XatiX/fix/libkernel-net-socket-forwards
fix(libkernel): forward socket calls on sceNetSocket descriptors to libSceNet
2026-11-03 21:08:43 +13:00
Dean e41879d2b7 Merge pull request #14876 from roboterspinne/fix/libkernel-ipv6-unspecified-connect
fix(libkernel): connect an AF_INET6 socket to ::1 when the address is unspecified, as FreeBSD does
2026-11-03 18:11:16 +13:00
Dean 7a3d08c1c3 Merge pull request #14875 from roboterspinne/fix/libkernel-tcp-multicast-address
fix(libkernel): fail bind and connect of a stream socket to a multicast address with EAFNOSUPPORT
2026-11-03 18:11:11 +13:00
orezraeyandClaude Opus 5.5 125a0d5c55 Merge main into fix/libkernel-ioctl-empty-request-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 19:45:25 -03:00
Dean 9551c50ff7 Merge pull request #9713 from simonbronk/feat/libkernel_sys-switch-utrace-tcsetsid
feat(libkernel_sys): implement scePthreadMutexIsowned, utrace and tcsetsid
2026-11-03 11:34:44 +13:00
JJenkxandClaude Opus 5.5 db6c0dae18 fix(libkernel): reject socket readiness after a concurrent close
Both waits re-checked the held sockets only before each host wait. A
close during the last slice, or one followed by a packet the retained
native socket then received, came back as a timeout or as readiness on
a descriptor that no longer exists. FreeBSD 11.4's pollrescan reports
POLLNVAL alone for such a descriptor.

The held sockets are now re-checked after every successful host wait as
well, select's socket group fails with EBADF, and poll reports POLLNVAL
without ORing in the native socket's readiness.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 16:22:14 -05:00
JJenkxandClaude Opus 5.5 2159dd620b fix(libkernel): notice a socket closed during poll or select
Both waits held the guest sockets they polled and handed the host one
poll call for the whole wait. A guest close dropped only the table entry,
so the native socket stayed open and the wait ran to its timeout: poll
returned 0 instead of POLLNVAL, and select reported EBADF only after its
next 100 ms re-lookup, or not at all when the timeout was shorter.
FreeBSD 11.4 wakes such a waiter and reports the closed descriptor.

Waits that include sockets now poll the host in slices of at most 10 ms
and, before each slice, check that every descriptor still maps to the
socket it held. A closed one answers POLLNVAL from poll and EBADF from
select.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 16:22:14 -05:00
orezraeyandClaude Opus 5.5 cf7da83495 Merge main into fix/libkernel-ioctl-empty-request-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 18:17:19 -03:00
Dean Galvin 5d23aa8b2e Merge commit 'f7d225d8e36cc19025e3bdf28e6f6ed345ab9506' into HEAD
# Conflicts:
#	core/libs/tests/GuestSelect.cpp
2026-11-03 08:54:29 +13:00
Dean 36896d8a7f Merge pull request #14206 from JJenkx/windows/libkernel-select-close-race
fix(libkernel): fail a select with EBADF when its pipe closes during the wait on Windows
2026-11-03 08:46:47 +13:00
Federico Marras 924439201b fix(libkernel): fail a send on a never-connected stream socket with ENOTCONN
send, sendto without an address, sendmsg and write on a stream socket on
which connect was never called, that was not accepted and that was not
received in a message now fail with ENOTCONN without asking the host, as
FreeBSD 11.4's sosend_generic does. Linux answered EPIPE and raised its
own SIGPIPE, which killed the guest.
2026-11-02 18:50:38 +01:00
Dean Galvin 73cebee9e1 Merge commit 'a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8' into HEAD
# Conflicts:
#	core/libs/prx/libkernel/Socket/src/Udp.cpp
2026-11-03 06:36:11 +13:00
XatiXandClaude Opus 5.5 7a4fa3865b fix(libkernel): keep the libkernel contract on forwarded socket calls
bind, getsockname, sendto and recvfrom validate as for a libkernel socket
before they reach libSceNet, so a forwarded descriptor reports the same
errors. recvfrom keeps its guest address handling and MSG_WAITALL, and a
zero-length datagram receive does not wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 17:33:10 +00:00
XatiXandClaude Opus 5.5 91311f1bf4 fix(libkernel): forward socket calls on sceNetSocket descriptors to libSceNet
A title can create a socket with sceNetSocket and then call bind, getsockname, sendto or recvfrom from libkernel, which does not hold that descriptor, so the call failed with EBADF. PPSA06866's RakNet does this, its local server fails to start and the load after difficulty selection never ends. libSceNet now registers these four calls with libkernel, as it does for setsockopt and getsockopt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 17:32:55 +00:00
Dean a4eca2a056 Merge pull request #13752 from Gruzzberry/fix/sockopt-efault
fix(libkernel): fail getsockopt and setsockopt with EFAULT on an unusable pointer
2026-11-03 06:31:52 +13:00
Dean bc12e15225 Merge pull request #13695 from Retr0G28/fix/ioctl-fioclex-socket
fix(libkernel): set and clear close-on-exec with FIOCLEX and FIONCLEX on a socket
2026-11-03 06:31:41 +13:00
Dean Galvin feef6c2197 Merge commit '4f64f81ef7b4bca975b4b9f3dfd15dfff56f716f' into HEAD
# Conflicts:
#	docs/dev/debt/libkernel.md
2026-11-03 02:42:46 +13:00
Dean 12936182c4 Merge pull request #11445 from MaxLikesCode/fix/dup2-socket-closes-kqueue
fix(libkernel): drop the kqueue and knotes of a descriptor that dup2 replaces with a socket
2026-11-02 23:28:02 +13:00
Dean 4ad64dc78b Merge pull request #11281 from Gruzzberry/fix/sockname-faults
fix(libkernel): fail getsockname and getpeername with EFAULT on an unusable pointer
2026-11-02 23:27:29 +13:00
roboterspinne 14fe943513 fix(libkernel): fail bind and connect of a stream socket to a multicast address with EAFNOSUPPORT 2026-11-01 22:28:23 +01:00
roboterspinne 255fa04a15 fix(libkernel): connect an AF_INET6 socket to ::1 when the address is unspecified, as FreeBSD does 2026-11-01 22:25:36 +01:00
Dean Galvin dcdf0e323b Merge commit 'f1a7b02028ae50adaf6c5aaaef892a51841b25bf' into HEAD
# Conflicts:
#	docs/dev/debt/libkernel.md
2026-11-02 02:09:19 +13:00
Dean 929e8d8442 Merge pull request #7090 from milescoviello/feat/scm-rights
feat(libkernel): pass descriptors in SCM_RIGHTS messages on Unix sockets
2026-11-02 02:06:02 +13:00
Adrià cae3edaf11 Merge pull request #13738 from Gruzzberry/fix/poll-efault
fix(libkernel): fail poll with EINVAL when nfds exceeds the descriptor limit
2026-11-01 01:40:45 +01:00
Adrià 577fe6329e Merge pull request #13756 from Gruzzberry/fix/recvfrom-sendto-efault
fix(libkernel): fail sendto and recvfrom with EFAULT on an unusable pointer
2026-11-01 00:54:10 +01:00
Dean Galvin c27d72435d Merge main into feat/libkernel_sys-switch-utrace-tcsetsid 2026-11-01 12:50:11 +13:00
JJenkxandClaude Opus 5.5 6157b85375 fix(libkernel): fail a select with EBADF when its pipe closes during the wait on Windows
On Windows, closing a pipe while another thread waited for it in select
terminated the process. The close releases the host handle before the C
runtime descriptor, so in between:

- the readiness query of the pipe failed on the dead handle and threw
  'querying pipe descriptor ... failed';
- after that, DescriptorIsOpen still saw the descriptor mapped, select
  looked it up again, found no known kind and threw 'is neither a
  socket, a pipe, ...'.

QueryPipe now reports a descriptor whose handle is no longer a pipe as
not a pipe instead of throwing, DescriptorIsOpen on Windows also checks
that the mapped handle is still valid, and select answers EBADF for such
a descriptor before throwing for an unknown kind, as FreeBSD 11.4's
kern_select does for a descriptor closed during the wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 19:19:53 -04:00
Evrim Cicek dd77feaf7f fix(libkernel): report a socket shut for reading in poll and select and wake their waiters 2026-10-31 18:29:27 +03:00
GruzzberryandClaude Sonnet 5.5 0d2ae1a300 fix(libkernel): release both socketpair descriptors when the copyout or registration throws
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-31 11:43:00 +00:00
GruzzberryandClaude Sonnet 5.5 6f42ff85b5 fix(libkernel): fail socketpair with EFAULT on an unusable result pointer
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-31 11:31:59 +00:00
GruzzberryandClaude Sonnet 5.5 ba9200abc0 fix(libkernel): fail poll with ENOMEM when the descriptor copy cannot be allocated
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-31 11:16:20 +00:00
GruzzberryandClaude Sonnet 5.5 028b2b5336 fix(libkernel): fail poll with EINVAL when nfds exceeds the descriptor limit
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-31 11:16:10 +00:00
GruzzberryandClaude Sonnet 5.5 736f3c9d41 fix(libkernel): fail sendto and recvfrom with EFAULT on an unusable pointer
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-31 11:06:56 +00:00
GruzzberryandClaude Sonnet 5.5 1f2365a5d1 fix(libkernel): fail getsockopt and setsockopt with EFAULT on an unusable pointer
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-31 04:02:34 +00:00
Adrià a46b04dfe1 fix(libkernel): ignore unwritable sbytes in sendfile and bound iovec allocation 2026-10-31 02:16:45 +01:00
pushkarreddyy ed0892da42 fix(libkernel): return EFAULT from sendfile for invalid memory pointers 2026-10-31 02:16:33 +01:00