fix(libkernel): return EOPNOTSUPP when connecting to a listener #6950
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6950"
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 MarcZX10 on 2026-10-16T20:52:56Z.
What
Return FreeBSD's
EOPNOTSUPP(45) whenconnect()targets a listening stream socket. Convert and validate the supplied address first, so null and short addresses keep their address errors; the listener check remains before the address-family check. Adds a focused regression test for listener errors, address-validation order, a cross-family address, and continued accept/connect behavior.Closes #6923.
The two implementation commits preserve Hussein Kadhim's authorship. They were rebased onto current
main(4986aca62e5984de1a34531648af7c987e40eb5d); the address-ordering commit needed a manual resolution inUdp.cppto retain current main's Windows closed-loopback handling before the listener check.#6884 also inserts a separate port-zero check in
connect_nid_postfixand a helper inUdp.cpp. These behaviors are independent. If #6884 merges first, rebase this PR and retain both checks. The otherUdp.cppoverlap reported with #6828 is in native socket lookup, separate from this connect behavior. SharedCMakeLists.txthunks from the overlap report were manually checked; the other PRs add different source files, tests, or platform-specific handling.Tested
git diff --checkandpython3 tools/check_conventions.py --base upstream/mainpass.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 github-actions[bot] on 2026-10-16T21:04:33Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/Socket/src/Udp.cppImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T21:50:07Z.
Linux run of this head, since the description says no local build or runtime result is claimed for it (the Windows runs it cites were on the branch before the rebase).
Setup: head
0d188ba6b(based onmain4986aca62), Release,BUILD_TESTING=ON, CachyOS (kernel 7.2.9), i9-11900K, GCC 16.2.1. Tests ran underenv -iwith onlyHOMEandPATHset (configure and build used the normal shell environment). Each arm ranctest -R ^guest_socket(10 tests,guest_socket_connect_listeningamong them) 3 times.Udp.cppas on4986aca62(the 6 added lines removed) and the new test kept,guest_socket_connect_listeningfails 3 of 3 withconnect on a listening socket must fail with EOPNOTSUPP (45) (errno 56), and the other 9 pass. 56 is FreeBSD'sEISCONN. By reading, without the check the call reaches the hostconnect, which on Linux fails withEISCONNfor a listening TCP socket (__inet_stream_connectinnet/ipv4/af_inet.c), and that is translated to 56.mainate9a3343a2: clean merge, 10 of 10 pass in each of the 3 runs.By reading the FreeBSD 11.4 source (not checked on PS5 hardware), the PR's order matches it:
sys_connectrunsgetsockaddrfirst (null-address and length errors), thenkern_connectat→soconnect→soconnectatreturnsEOPNOTSUPPforSO_ACCEPTCONN. That is before the protocol connect runs:tcp_usr_connectchecks the address length, andin_pcbconnect_setupchecks the family.git merge-treeof this head with #6884 (629c069c1) reports a conflict inUdp.cpp, as the description anticipates. Whichever merges second needs a rebase that keeps both checks.Not checked: Windows on this head, where
RefuseClosedLoopbackAtOnce_nid_no_patchruns before the listener check (by reading, a loopback address with no listener on the port getsSIO_TCP_INITIAL_RTOset on the listening socket beforeEOPNOTSUPPreturns; the new test does not reach that case). Also not checked: macOS, an IPv6 listener (the test's listener is IPv4), datagram sockets (the check applies only whensocket->type == 1), and behaviour on PS5 hardware.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T22:14:39Z.
Thanks for the independent Linux run and the revert comparison. The three repeated
guest_socketruns pass on this head, and the revert consistently exposes theEISCONNversusEOPNOTSUPPdifference; the clean merge-tree result with #6884 is useful too. I have noted the limits you called out: Windows/macOS, IPv6, datagram sockets, and PS5 hardware were not covered. I have not run those checks locally.