fix(libkernel): fail a short or long socket address like FreeBSD #4920
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4920"
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 xXPBSXx on 2026-10-13T04:13:22Z.
What
bind,connectandsendtoon a libkernel socket checked the guestsockaddrlength inAddress()(Udp.cpp) with rules of their own: a length below 2 failed withEFAULT(14), and anAF_INETaddress below 16 or anAF_INET6address below 28 bytes withEAFNOSUPPORT(47). FreeBSD 11.4 answers these differently:getsockaddrfails a length aboveSOCK_MAXADDRLEN(255) withENAMETOOLONG(63) and a length belowoffsetof(struct sockaddr, sa_data)(2) withEINVAL(22).sa_len) withsizeof(struct sockaddr_in)/sockaddr_in6and fail a mismatch withEINVAL(tcp_usr_connect,in_pcbconnect_setup). A null address with a length of 2 to 255 isEFAULT(copyin), as before; a null address with a length below 2 now fails withEINVALand one above 255 withENAMETOOLONG, becausegetsockaddrchecks the length before it copies (read inrelease/11.4.0).Address()now returns these three errors. A full-size address is unchanged. Not changed, because the console's answer is not known: an address longer thansockaddr_in/sockaddr_in6is still accepted (FreeBSD saysEINVAL), and a different family still fails withEAFNOSUPPORT. Both are in the TechnicalDebt entry.No title evidence: found by writing failure-path tests from the FreeBSD source (see Tested), no title I ran passes a short address. This is FreeBSD conformance.
Overlap: the overlap bot lists no pull request for this one, and
git merge-treeof the head9fc03d33aagainstmainbf8dc610eis clean (checked, not rebuilt). The test registration sits beforeguest_socket_read_writeincore/libs/prx/libkernel/CMakeLists.txtand the TechnicalDebt entry after thesend, sendtoentry inlibkernel.md, away from the places the other socket PRs use. #5565 (Dripl1x,TCP_NODELAY,SO_NOSIGPIPEandSO_NBIO) conflicts with this PR indocs/dev/debt/libkernel.md(git merge-treeof the two heads, re-checked againstmaince5c83953; both heads are clean againstmain); whichever lands second rebases the debt entry.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, on
mainc2565f014; moved since to a newermain(git merge-treeagainstmainbf8dc610eis clean; not rebuilt there) with its test registration and debt entry at their own places:guest_socket_address_length(new) passes: lengths 0, 1, 3, 8, 15 (AF_INET), 20 (AF_INET6) fail withEINVAL, 256 withENAMETOOLONG, a null address withEFAULT, a fullsockaddr_instill binds.Udp.cpp(connect with a length below the size of sa_family must fail with EINVAL (22) (errno 14)).guest_udp,guest_tcp,guest_sce_net,guest_poll,guest_dup,guest_select,guest_socket*): pass together with the new one.python tools/check_conventions.py --base upstream/mainpasses.main0f2683cb7:guest_socket_address_lengthtakes 0.21 s (ctest, serial, Windows). The fullguest_*/ libc / libkernel group passes (391 of 391, 0 failed; the build also contains the other branches of this series).2e553b97c(test only):guest_socket_address_lengthnow checks the result ofsocket(AF_INET6, ...)and closes that socket (before, a host without IPv6 would have answeredEBADFinstead ofEINVAL, and the descriptor stayed open). Rebuilt and run on the new head (base1e7f4967e, Windows 10, MinGW GCC 15.2.0, Release,-j4):guest_socket_address_lengthpasses; withUdp.cpptaken back to the base it fails (connect with a length below the size of sa_family must fail with EINVAL (22) (errno 14));python tools/check_conventions.py --base upstream/mainpasses.Checklist
main; no other open PR implements the same functions (overlaps described above)NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (docs/dev/debt/libkernel.md).mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:36:19Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed