fix(libkernel): refuse socketpair records longer than the send buffer with EMSGSIZE #18767
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18767"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by EEkebin on 2026-11-12T07:15:39Z.
What
A Unix
SOCK_DGRAMorSOCK_SEQPACKETsocketpair end now refuses a record longer than its send buffer withEMSGSIZE, as FreeBSD 11.4'ssosend_genericdoes for atomic protocols (resid > so_snd.sb_hiwat). The limit is the end's ownSO_SNDBUF: 2048 bytes for datagrams (net.local.dgram.maxdgram) and 8192 for seqpacket by default, or whatever the guest set. Before this, the host sent such records: a loopback UDP socket on Windows and anAF_UNIXsocket with a ~200 KiB buffer on Linux.The check follows
sosend_generic's order. A send-shut end still fails withEPIPE, and an end whose peer is gone keeps its current errors. The check comes before the null-bufferEFAULT, because FreeBSD copies the data only after this check.send,sendto,sendmsg,writeandwritevall reach it, becausewrite/writevgo throughsendandsendmsggoes throughsendto. The debt entry no longer lists the missingEMSGSIZE.Tested
Windows 11 Enterprise 10.0.26200, i7-13700K, WinLibs GCC (MinGW-w64), Release:
guest_socket_pairchecks the datagram pair. Without the library change it aborts (0xc0000409); with it, it passes.SO_SNDBUF;send,sendto,sendmsg,writeand a null buffer at one byte over the limit;SO_SNDBUF;SO_SNDBUFbelonging to each end separately;EPIPEwinning aftershutdown(SHUT_WR).ctest -R 'socket|poll|select|kqueue|dup|pipe|sendfile|fstat|recv|send|shutdown|fcntl|net': 323/323 passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T08:35:25Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
5a7a749d12:tools/check_conventions.pypassed;git diff --checkclean.guest_socket_pair_testsbuilt cleanly.guest_socket_pair,guest_recvmsg_memory):core/libs/prx/libkernel/Socket/include/SocketOptions.hpp,core/libs/prx/libkernel/Socket/src/SocketOptions.cpp,core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Generated withfooter from the description; the AI-assisted checkbox can stay.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T10:14:18Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
5a7a749d12:tools/check_conventions.pypassed;git diff --checkclean.guest_socket_pair_testsbuilt cleanly.guest_socket_pair,guest_recvmsg_memory):core/libs/prx/libkernel/Socket/include/SocketOptions.hpp,core/libs/prx/libkernel/Socket/src/SocketOptions.cpp,core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me