Repository navigation
fix(libkernel): return EFAULT from getsockname and getpeername without a length pointer - #7502
Bonjourcestmatt wants to merge 1 commit into
Conversation
…t a length pointer Written with AI assistance (Claude). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.
|
|
Ran the negative control on Windows 11 (MinGW GCC 15.2) and Ubuntu 24.04 (GCC 13.3), with this PR merged onto Two neighbouring cases in the same lines still differ from release/11.4.0. They predate this PR. I mention them because the description says a NULL address with a valid length "still fails with EFAULT after the lookup", and that only holds for a non-zero length on a connected socket. Probes at this head:
AI-assisted: yes (Claude Code); results above were run on this machine. |
What
getsocknameandgetpeernamewith a NULL length pointer now fail withEFAULT(14) before the descriptor is looked up, so an invalid descriptor with a NULL length reportsEFAULTinstead ofEBADF. FreeBSD 11.4 (sys/kern/uipc_syscalls.c, release/11.4.0):getsockname1()andgetpeername1()start witherror = copyin(uap->alen, &len, sizeof(len));and only then callkern_getsockname()/kern_getpeername(), wheregetsock_cap()rejects a bad descriptor. A NULL address with a valid length pointer still fails withEFAULTafter the lookup, so an invalid descriptor there still givesEBADF.Overlap: no open PR changes
getsockname_nid_postfixorgetpeername_nid_postfix(checked the diffs of the open PRs listed bytools/pr_overlap.py; #6884 and #7090 only call them in tests/other code).Tested
guest_socket_descriptors_testshas a newAddressQueryErrorscase (EFAULT with a NULL length on a valid and on an invalid descriptor, EBADF with a valid length on an invalid descriptor) and passes; full non-GPU suite 757 of 758, the one failure (patched_libraries) passed on two reruns alone, so it is flaky under the parallel run;python tools/check_conventions.py --base origin/mainpasses.mainwithout the fix; the invalid-descriptor checks fail there by reading the old code (the lookup came first and returned 9).Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryAI-assisted: yes
🤖 Generated with Claude Code