Repository navigation
fix(libkernel): check socket address arguments before the descriptor - #8392
Conversation
|
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.
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.
|
|
Overlap note: #7511 (validate the pointers of getsockopt and setsockopt like FreeBSD) adds the same null-value and negative-length checks for |
bind, connect and sendto looked the descriptor up before they looked at the address length, so a descriptor that is not open hid an argument error. FreeBSD 11.4 sys_bind, sys_connect and sendit run getsockaddr first (ENAMETOOLONG, EINVAL, EFAULT) and only then look the descriptor up, so these arguments are now answered first and EBADF only follows for a valid address. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
943db32 to
ce8f780
Compare
|
Thanks, the ordering matches FreeBSD's |
|
Thanks, you are right: the diff changes only the address checks of |
|
Linux data point for AI-assisted (Claude Code). |
|
Checked the order of |
What
AddressLengthError(the length and null checks ofAddress(), i.e. FreeBSDgetsockaddr) now runs beforeLookup()inbind,connectandsendto(only when an address is given). Valid arguments on a closed descriptor still fail with EBADF; the family and short-AF_INET checks stay after the descriptor lookup.Fixes #8391
Follow-up to #8154 (socket address length).
setsockoptis not changed here; the pointer and length checks ofsetsockopt/getsockoptare in #7511.git merge-treeagainst the open socket PRs #7490, #7850, #7475 and #8312 is clean;pr_overlapwas not run.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main d50ec76 + this commit:
guest_socket_address_lengthfails without the change toUdp.cpp(bind(-1)with a 1-byte address answers 9) and passes with it; 28 other socket and sceNet tests pass (29 of 29);python tools/check_conventions.py --base upstream/mainpasses. Not tested: Linux/macOS, a console, a title run.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code