fix(libkernel): return EFAULT from accept for an address buffer without a length pointer #7485
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7485"
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 Bonjourcestmatt on 2026-10-18T09:09:55Z.
What
acceptwith an address buffer but no length pointer now fails withEFAULT(14) instead ofEINVAL(22), and that check now comes before the descriptor lookup. FreeBSD 11.4accept1()(sys/kern/uipc_syscalls.c, release/11.4.0) returns early when the name is NULL; otherwise it doeserror = copyin(anamelen, &namelen, sizeof (namelen)); if (error != 0) return (error);before callingkern_accept4(), which is wheregetsock_cap()rejects a bad descriptor. So a missing length pointer reportsEFAULTeven on an invalid descriptor. A non-listening socket still fails withEINVAL, askern_accept4()does onSO_ACCEPTCONNbeing clear.Overlap: no open PR changes
accept_nid_postfix(checked the diffs of all open PRs touchingSocket/src/Udp.cpp, andtools/pr_overlap.py; #7140 and #6663 only call it in tests).Tested
guest_socket_connect_listening_testshas three new checks (EFAULT with a listening socket, EFAULT before EBADF, EBADF without an address); all 22 socket ctest tests pass and the full non-GPU suite passes (756 of 756, skipped ones included);python tools/check_conventions.py --base origin/mainpasses.mainwithout the fix; the first one fails there by reading the old code (it returned 22).Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryAI-assisted: yes
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T10:09:45Z.
Review: COMMENTED
Linux run, since the description lists only Windows and notes the new checks were not run against
main.Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release,
BUILD_TESTING=ON, full build.Head
5052a3f3bmerged ontomain9caecfd2d(clean merge).guest_socket_connect_listeningpasses with the three new checks, as do the other socket/network tests (ctest -R "socket|udp|tcp|accept", 16 tests).GuestSocketConnectListening.cpponly, onmain: fails ataccept with an address buffer and no length pointer must fail with EFAULT (14) (errno 22), so the first new check catches the old order.ctest -E "^agc|gpu|vulkan|video_out"): 712/712, same asmain.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T02:49:24Z.
Independent Windows run of this PR (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against
mainis clean. I built onlyguest_socket_connect_listening_tests;ctest -N -R guest_socket_connect_listeninglists exactly one test.Results (3 runs each):
guest_socket_connect_listeningpasses 3/3.core/libs/prx/libkernel/Socket/src/Udp.cppwith the version from the PR's merge base (cdb7ed0355), then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed Require). I restored the PR's file afterwards.Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.
AI-assisted (Claude Code).