Commit Graph
331 Commits
Author SHA1 Message Date
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
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
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
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
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
Dean e0a11b3fba Merge pull request #9515 from EagleBearerYS/fix/libkernel-getsockopt-net-sockets
fix(libkernel): getsockopt reads options of libSceNet sockets
2026-10-29 18:49:11 +13:00
milescovielloandClaude Opus 5.5 1e19b327f7 fix(libkernel): refuse a JIT shared memory descriptor in SCM_RIGHTS, and use the renamed kqueue check
sceKernelJitCreateSharedMemory's size object and maximum protection live
in libkernel's g_jitDescriptors, which the receive side of SCM_RIGHTS
doesn't fill, so a received JIT descriptor failed
sceKernelJitMapSharedMemory with EBADF (XairRrR's review). Passing one
now throws, with the random device and directory cases; IsJitSharedMemory
answers it. The merge of main brought #11296's rename of
IsKqueueDescriptor to IsKqueueDescriptor_nid_no_patch, which the kqueue
check now calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 05:47:55 +00:00
milescoviello 9409deaa87 Merge remote-tracking branch 'upstream/main' into feat/scm-rights 2026-10-29 05:47:11 +00:00
milescovielloandClaude Opus 5.5 b9e987b82e fix(libkernel): refuse to pass a guest kqueue, a random device or a directory in SCM_RIGHTS
A guest kqueue and a guest /dev/urandom are /dev/null placeholders with
their behaviour in libkernel's tables, and a guest directory descriptor
keeps its reading state there too. sendmsg sent the placeholder, and the
receiver got a descriptor that failed kevent or read as empty. FreeBSD's
unp_internalize returns EOPNOTSUPP for a kqueue (no DFLAG_PASSABLE), so a
kqueue now gets that; a random device or a directory throws.

A zero-byte sendmsg carrying descriptors on a stream socket returned 0
and lost them, as Linux sends no record without data. It throws now.
FreeBSD sends the control data alone there.

guest_socket_rights checks the kqueue refusal and that the next send on
the pair arrives without control data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 04:21:45 +00:00
slopgobblercobbler 9d41d12f64 fix(libkernel): classify guest sockets on Windows and align errno parity 2026-10-29 00:45:11 +01:00
Adrià 027989a44a Merge pull request #11858 from jotitadev/fix/macos-poll-hangup-both-directions
fix(libkernel): report POLLHUP on macOS only once both directions of a stream have ended
2026-10-28 18:20:12 +01:00
ruby_sc 9a4d2462d3 fix(libkernel): verify UDP disconnect outcomes after native errors
Reuse the macOS disconnect prerequisite in the common POSIX path. Proceed only when getpeername positively reports ENOTCONN, retaining the original connect error for connected or indeterminate sockets.

Exercise actual UDP sockets with injected EAFNOSUPPORT and EINVAL results for IPv4 and IPv6, both disconnect entry points, all three binding modes, and still-connected or failed peer-query outcomes.
2026-10-28 13:36:25 -03:00
ruby_sc 302ddacc21 fix(libkernel): integrate macOS UDP disconnect prerequisite 2026-10-28 13:36:25 -03:00
ruby_sc 8478890c36 fix(libkernel): serialize UDP address state transitions
Keep native UDP bind, connect and disconnect operations coherent with the shared reported-address state. Reuse the existing connect lock and avoid additional locking on stream sockets.

Add a controlled overlapping disconnect/reconnect regression and check truncated address writes after disconnection. Clear an obsolete IPv6 scope ID when reporting the wildcard address.
2026-10-28 13:36:25 -03:00
ruby_scandxXPBSXx 55e1557a1f fix(libkernel): clear reported local address after UDP disconnect
Preserve the local port while reporting a wildcard address after a datagram association is dissolved. Share the state across descriptor aliases and clear it on a successful bind or reconnect.

Adapted from the fix branch linked in issue #8681, with expanded binding, reconnect and descriptor-alias regression coverage.

Co-authored-by: xXPBSXx <[email protected]>
2026-10-28 13:36:25 -03:00
babyhuey 9f5b24630d fix(libkernel): return EFAULT from pselect for an unreadable timeout or signal mask
pselect read its timeout directly, passed the guest signal mask straight
to SetSignalMaskCatching_nid_no_patch, which dereferences it, and saved
and restored the descriptor sets with memcpy after a caught signal, so a
non-null pointer into unmapped or read-only memory crashed the host. It
now copies the timeout and the mask in with GuestCopyIn_nid_no_patch,
as FreeBSD's sys_pselect does before changing the mask, and saves and
restores the sets with GuestCopyIn_nid_no_patch and
GuestCopyOut_nid_no_patch, failing with EFAULT. A bad timeout or mask
leaves the thread's signal mask unchanged.
2026-10-28 12:18:17 -04:00
babyhuey 364a28eb2d fix(libkernel): return EFAULT from poll for an unreadable or unwritable descriptor array
poll read and wrote the guest pollfd array in place, so a non-null array
in unmapped or read-only memory crashed the host. It now copies the
array in with GuestCopyIn_nid_no_patch, polls the local copy and copies
the results back with GuestCopyOut_nid_no_patch, failing with EFAULT
like FreeBSD's copyin and copyout. Timeout validation still comes
first, and a failed poll copies nothing back.
2026-10-28 08:24:59 -04:00
AdriàandClaude Sonnet 5.5 f87b6289ac fix(libkernel): export the kqueue descriptor check to libkernel_sys
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-28 08:43:15 +01:00
Yunus Shaikh 4432e8aa57 Merge main into fix/libkernel-getsockopt-net-sockets 2026-10-27 21:03:12 -07:00
milescovielloandClaude Opus 5.5 1db8d77c9a fix(libkernel): own received descriptors until recvmsg has written its whole result
A fault on the final message header write, or an installation that fails
part-way, now closes every received descriptor exactly once. A plain-data
MSG_PEEK with control space on a Unix socket reads the data again, as on
main, and the test includes the public headers and counts host descriptors
portably.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 23:03:09 +00:00
Jota 8bed63610b fix(libkernel): report POLLHUP on macOS only once both directions of a stream have ended
XNU's poll reports POLLHUP as soon as either direction of a stream socket has ended, adds POLLPRI and POLLRDBAND to it and then drops POLLOUT. FreeBSD's sopoll_generic reports POLLHUP only once the receive and the send side are both shut, and Linux does the same, so on macOS a guest saw POLLIN|POLLHUP for a stream whose peer had only shut its sending side, and POLLHUP for one that had only shut its own.

When the host reports POLLHUP on a guest stream socket, ask it about each direction alone and keep POLLHUP only when both have ended, report the requested POLLOUT while the sending side is shut or writable, and leave urgent data to SIOCATMARK.
2026-10-27 06:55:16 -03:00
milescoviello 1aa584d11e Merge remote-tracking branch 'upstream/main' into feat/scm-rights
# Conflicts:
#	core/libs/prx/libkernel/Socket/src/Udp.cpp
#	docs/dev/debt/libkernel.md
2026-10-27 05:17:16 +00:00
milescoviello 8f7e0188d0 Merge remote-tracking branch 'upstream/main' into feat/scm-rights
# Conflicts:
#	core/libs/prx/libkernel/Socket/src/Udp.cpp
2026-10-26 22:05:03 +00:00
Evrim Cicek 3f67bbcd4e Merge branch 'main' of https://github.com/boykopovar/AnyPS5 into fix/recvmsg-after-shut-rd
# Conflicts:
#	core/libs/prx/libkernel/Socket/src/Udp.cpp
#	docs/dev/debt/libkernel.md
2026-10-27 01:04:45 +03:00
Dean 94d981d20b Merge pull request #11194 from orezraey/fix/libkernel-socket-address-length-first-measured-ps5
fix(libkernel): check the socket address length before its family as measured on a PS5
2026-10-27 11:02:40 +13:00
Dean d018922066 Merge pull request #11141 from orezraey/fix/libkernel-recvmsg-timestamps-measured-ps5
fix(libkernel): report SCM_BINTIME and SCM_TIMESTAMP from recvmsg as measured on a PS5
2026-10-27 11:01:32 +13:00
Dean 5dd28e5682 Merge pull request #11135 from orezraey/fix/libkernel-dupfd-cloexec-measured-ps5
fix(libkernel): fail F_DUPFD_CLOEXEC and make F_DUP2FD_CLOEXEC ignore its target as measured on a PS5
2026-10-27 11:01:17 +13:00
Dean be0bbc6518 Merge pull request #11006 from harisibrar1/fix/so-acceptfilter-einval
fix(libkernel): fail SO_ACCEPTFILTER with EINVAL on a socket that is not listening
2026-10-27 10:59:07 +13:00
Dean 77d9056574 Merge pull request #10949 from AZLisme/feat/net-ipv6only
feat(libSceNet): support IPv6 dual-stack socket options
2026-10-27 10:57:32 +13:00
Dean 9021e9b66e Merge pull request #10621 from Retr0G28/fix/socketpair-fstat-inode
fix(libkernel): report NODEV and a per-socket inode from fstat on a socketpair end
2026-10-27 10:30:31 +13:00
Retr0 d99208fa84 Merge remote-tracking branch 'origin/main' into fix/socketpair-fstat-inode
# Conflicts:
#	core/libs/prx/libkernel/Socket/src/Udp.cpp
#	docs/dev/debt/libkernel.md
2026-10-26 21:09:20 +02:00
011010 9e23a9263c fix(libkernel): report urgent data in poll on macOS
XNU's poll never reports POLLPRI for out-of-band data, so a guest poll
that asks for it never sees the urgent byte: guest_poll aborts at the
OOB case and a title waiting on priority data would sleep to its
timeout.

On macOS the pending byte is read from SIOCATMARK, which reports it
without consuming it and has no descriptor limit, unlike the fd_set
probe this replaces. POLLRDBAND is set with POLLPRI as FreeBSD 11.4's
sopoll_generic does, and the wait takes the sliced path main already
uses for a kqueue wait, so it wakes on the next slice instead of at the
deadline.

recv(MSG_OOB | MSG_PEEK) was measured to consume the byte on macOS
27.0.1 and kevent with NOTE_OOB does not fire there, which is why the
probe is SIOCATMARK. The select and libSceNet poll paths still miss
urgent data on macOS and are recorded in the debt entry.
2026-10-26 13:00:51 -06:00
AZLisme ada64cab1e fix(net): preserve IPv6 socket option bridges in patched modules 2026-10-26 19:16:52 +08:00
AZLisme e846e0c7b2 fix(libSceNet): guard socket option guest outputs 2026-10-26 19:16:52 +08:00
Dean 9ab54a34b8 Merge pull request #11251 from orezraey/fix/libkernel-tcp-maxseg-measured-ps5
fix(libkernel): refuse TCP_MAXSEG before a connection and raise it to 216 as measured on a PS5
2026-10-26 22:11:42 +13:00
orezraeyandClaude Opus 5.5 85a1bf2b31 Merge main into fix/libkernel-dupfd-cloexec-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 23:27:02 -03:00
harisibrar1 7746b7a6f9 Merge remote-tracking branch 'origin/main' into fix/so-acceptfilter-einval 2026-10-25 21:44:28 -04:00
harisibrar1andClaude Opus 5.5 ce11ee1487 fix(libkernel): answer SO_ACCEPTFILTER on a datagram socket with EINVAL on Windows
Winsock does not answer SO_ACCEPTCONN on a datagram socket, so the
listening check returned the host error (ENOPROTOOPT). A datagram socket
can never listen, so it fails with EINVAL without asking the host, as
FreeBSD 11.4 does. Reported by @wachi35676.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 20:18:12 -04:00
orezraeyandClaude Opus 5.5 19566dbee8 fix(libkernel): set MSG_CTRUNC for an empty recvmsg control buffer as FreeBSD 11.4 does
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 21:05:10 -03:00
harisibrar1 7784604b0b Merge remote-tracking branch 'origin/main' into fix/pselect-pending-signal-eintr
# Conflicts:
#	core/libs/prx/libkernel/System/src/Signals.cpp
2026-10-25 19:35:03 -04:00