fix(libkernel): fail a socket call on an open non-socket descriptor with ENOTSOCK #4922
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4922"
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:17:30Z.
What
bind,listen,accept,connect,shutdown,getsockname,getpeername,getsockopt,setsockopt,send,recvand the other libkernel calls that look up a guest socket (Lookup()inUdp.cpp) answeredEBADF(9) for every descriptor that is not a guest socket. For a descriptor that is open but not a socket, for example a pipe end, FreeBSD 11.4 answersENOTSOCK(38):getsock_capreturnsENOTSOCKwhenfp->f_type != DTYPE_SOCKETand keepsEBADFfor a closed or invalid descriptor.Lookup()now fails withENOTSOCKwhen the descriptor is open (DescriptorIsOpen_nid_no_patch); guest sockets live in the descriptor table since #4391, soLookup()reaches this case only for a descriptor that is not a socket, and withEBADFotherwise.shutdownno longer overwrites the error ofLookup()withEBADF. Not changed:sendfilestill answersEBADFfor a destination that is not a socket (a separate path inUdp.cpp,finish(9)).No title evidence: found by writing failure-path tests from the FreeBSD source, no title I ran passes a non-socket descriptor to a socket call. This is FreeBSD conformance.
Overlap: the overlap bot lists no pull request for this one, and
git merge-treeof the head63dfc37d6againstmainbf8dc610eis clean (checked, not rebuilt). The test registration sits beforeguest_dupincore/libs/prx/libkernel/CMakeLists.txt, away from the other socket PRs;docs/dev/debt/libkernel.mdis not touched.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 at its own place:guest_socket_on_non_socket(new) passes (the test uses pipe ends as the open non-socket descriptors;getpeername,sendto,recvfrom,sendmsgandrecvmsguse the sameLookup()but have no case of their own):bind,listen,accept,connect,shutdown,getsockname,getsockopt,setsockopt,sendandrecvon an open pipe fail withENOTSOCK; the same calls on a closed pipe end, on -1 and on a descriptor that was never open keepEBADF.Udp.cpp(bind on a pipe must fail with ENOTSOCK (38) (errno 9)).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_on_non_sockettakes 0.25 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).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:13Z.
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