fix(libkernel): accept an address buffer without a length pointer in recvfrom #7507
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7507"
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-18T10:10:24Z.
What
recvfromwith an address buffer but no length pointer now succeeds and returns the received bytes, instead of failing withEFAULT(14) after the descriptor lookup. FreeBSD 11.4sys_recvfrom()(sys/kern/uipc_syscalls.c, release/11.4.0) only does thecopyinof the length whenfromlenaddris non-NULL; otherwise it setsmsg.msg_namelen = 0and still passesmsg.msg_name = uap->from.kern_recvit()then copiesMIN(len, fromsa->sa_len)bytes of the source address, which is zero bytes, so nothing is written and the receive succeeds. The address is only written back when the length pointer is present.Overlap: no open PR changes
recvfrom_nid_postfix.tools/pr_overlap.pylists PRs touchingUdp.cppandGuestSocketPair.cpp; I read the diffs of #7332, #6044, #6222, #7201 and #6977: only #7332 mentionsrecvfrom_nid_postfix, in a test line that passes a null address and a null length, which still behaves the same.Tested
guest_socket_pair_testshas a new check (a Unix streamrecvfromwith an address buffer and a null length pointer returns the data). It fails onmainwithout the fix (exit code 0xc0000409) and passes with it; all socket andsce_netctest tests pass and the full non-GPU suite passes (758 of 758, skipped ones included);python tools/check_conventions.py --base origin/mainpasses.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 wachi35676 on 2026-10-18T12:20:03Z.
Checked on Ubuntu 24.04 (GCC 13.3) as well as Windows 11 (MinGW GCC 15.2), with this PR merged onto
main9f25d0bf5.guest_socket_pairwith the new lines aborts withmain'sUdp.cppand passes with this PR on both. The socket/sce_net set passes (Linux 26/26, Windows 38/38).This matches release/11.4.0: without a length pointer,
sys_recvfromsetsmsg_namelen = 0(L1220), andkern_recvitthen copies 0 bytes (L1099).AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by ycarogabriel-lgtm on 2026-10-19T00:13:28Z.
Ran this on macOS, since it was not run there: Apple M1, macOS 26.6.2 (25G83), x86-64 build under Rosetta 2, AppleClang 21. Merged into the macOS host branch of #7332 (
57bccfbfc,mainatd71853cf2) together with #7121, #7475, #7490, #7507 and #7612;Releasebuild.guest_socket_pairpasses.guest_kqueuecase from #7121 that is unrelated to this change.AI-assisted: yes (Claude Code). I ran the build and tests on my machine.
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T09:53:31Z.
Review: COMMENTED
Checked head
911c6765cbmerged onto main16025845e5(merges clean; socket files are the same on mainacbfd7c7fe). Linux, WSL2 Ubuntu 24.04, GCC 13.3, Release,guest_socket_paironly.The merged tree crashes on a zero-length
recvfromwith an address and no length pointer. #8492 landed after this PR was opened and added an early return inrecvfrom_nid_postfixthat still does:Before this PR the EFAULT guard kept that safe. With the guard gone it writes through null. It's reached whenever
ReceiveAnsweredHerereturns 0: length 0 on a connected stream, length 0 on a datagram socket with nothing queued, or on Windows any length aftershutdown(SHUT_RD). The new test uses length 8, so it takes the host path and misses this.Repro, one line after your new check in
GuestSocketPair.cpp:guest_socket_pairSegFaultif (address && addressLength) *addressLength = 0;on that line: passesFreeBSD returns 0 there too:
msg_namelen = 0whenfromlenaddris NULL (L1220) and the length copyout is skipped (L1188). So a rebase plus that guard plus the zero-length test line should cover it. The host-path change itself looks right to me.AI-assisted: yes (Claude Code); the build and test above ran on this machine.
Pull request closed