fix(libkernel): fail socket() with EPROTOTYPE for an unknown type like FreeBSD #4993
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4993"
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-13T07:30:31Z.
What
libkernel
socketansweredEPROTONOSUPPORT(43) for every socket type it does not provide. FreeBSD 11.4'ssocreatetells the cases apart when no protocol matches:EPROTOTYPE(41);EPROTONOSUPPORT(43);EAFNOSUPPORT(47), unchanged.socket(AF_INET, 99, 0)andsocket(AF_INET6, 99, 0)now fail with 41,socket(AF_INET, 99, 6)andsocket(AF_INET, 0, 0)stay 43. Every other type that is not 1, 2 or 3 with protocol 0 (4 and 5 as well) now answers 41; the test covers 99 only, and which of these types the console provides is not known.SOCK_RAWstays 43 because libkernel does not provide raw sockets (FreeBSD would create one or answerEPERM; listed as a new entry in the TechnicalDebt file for libkernel); a stream socket with the UDP protocol and a datagram socket with the TCP protocol stay 43, aspffindprotofinds no match and a protocol was given.No title evidence: found by writing failure-path tests for
socketfrom the FreeBSD source; no title I ran passes an unknown type. This is FreeBSD conformance. The same change for thesceNetSocketof libSceNet is part of #4989.Overlap (checked with
git merge-treeagainst the heads of #4796, #4920, #4922, #4929, #4968 and #4989): no conflict. The new test is registered next toguest_pollso it does not collide with the other test registrations in that file. #4933 (poll libSceNet sockets with the host wait) conflicts with this PR indocs/dev/debt/libkernel.md(git merge-treeof the two heads, re-checked); whichever lands second rebases the debt entry. #5510 (simonbronk, EPIPE for a stream send after the peer closed) 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; the code is unchanged since, the branch is one commit onmain0f2683cb7and adds a TechnicalDebt entry forSOCK_RAW;git merge-treeof the headf53fea6efagainstmainbf8dc610eis clean (checked, not rebuilt):guest_socket_create_errors(new) passes: unknown type with protocol 0 (41, onAF_INETandAF_INET6), unknown type with a protocol (43), type 0 (43), stream with the UDP protocol (43), datagram with the TCP protocol (43), unknown family (47), and valid sockets still created.Udp.cpp(an unknown type with protocol 0 must fail with EPROTOTYPE (41) (errno 43)).guest_socket*,guest_udp,guest_tcp,guest_sce_net,guest_poll,guest_dup,guest_select) pass.python tools/check_conventions.py --base upstream/mainpasses.main0f2683cb7:guest_socket_create_errorstakes 0.26 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 functionsNotImplemented_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 github-actions[bot] on 2026-10-13T13:13:15Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libkernel.mdL153Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:34:45Z.
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