Commit Graph
372 Commits
Author SHA1 Message Date
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
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
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
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
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
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
Retr0 0c3ae34367 fix(libkernel): set and clear close-on-exec with FIOCLEX and FIONCLEX on a socket 2026-10-31 02:29:34 +02:00
Adrià bcee950a9c Merge pull request #12467 from Buraddomoon/fix/udp-disconnect-local-address
fix(libkernel): clear reported local address after UDP disconnect
2026-10-30 10:18:49 +01:00
Adrià 438cebf361 Merge pull request #10544 from maximilianfv/fix/libkernel-macos-datagram-disconnect
fix(libkernel): count a dissolved datagram association as disconnected on macOS
2026-10-30 01:03:08 +01:00
Adrià 788e5531a1 Merge pull request #12163 from slopgobblercobbler/fix/libkernel-windows-descriptor-socket-classification
fix(libkernel): classify guest sockets on Windows and align errno parity
2026-10-29 23:46:12 +01:00
SimoneandClaude Opus 5.5 eea3c721a7 Merge branch 'main' into feat/libkernel_sys-switch-utrace-tcsetsid
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 22:56:43 +01:00
Adrià 01f4e342d5 Merge pull request #12525 from babyhuey/fix/pselect-efault
fix(libkernel): return EFAULT from pselect for an unreadable timeout or signal mask
2026-10-29 14:59:14 +01:00
Adrià a12a2fcfc4 Merge pull request #12462 from babyhuey/fix/poll-efault
fix(libkernel): return EFAULT from poll for an unreadable or unwritable descriptor array
2026-10-29 14:39:55 +01:00
MaxandClaude Opus 5.5 dcdf9f35d5 fix(libkernel): drop the kqueue and knotes of a descriptor that dup2 replaces with a socket
dup2 from a guest socket notified the event queues only when the
replaced descriptor was itself a guest socket. A kqueue replaced this
way stayed registered, so kevent on the number that now names the
socket still returned the old queue's events, and knotes registered on
a replaced pipe or file stayed attached. FreeBSD 11.4's kern_dup closes
the replaced file through closefp, whose knote_fdclose drops every
knote on the descriptor, as the other dup2 paths here already do.

Fixes #11429

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 13:13:56 +01:00
slopgobblercobbler 60874d0098 fix(libkernel): return EFAULT from socket ioctl for invalid memory pointers
ioctl(FIONBIO) on a guest socket read its int argument directly, while ioctl(FIONREAD) wrote its int result directly, so passing a non-null pointer into unmapped or read-only memory crashed the host with an access violation. FIONBIO and FIONREAD are _IOW and _IOR requests, which FreeBSD copies in and out using copyin and copyout, returning EFAULT on inaccessible memory. The argument is now safely checked using GuestCopyIn_nid_no_patch and GuestCopyOut_nid_no_patch.
2026-10-29 12:03:11 +01:00