Repository navigation
fix(libkernel): fail socketpair with EFAULT on an unusable result pointer - #13742
Conversation
|
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.
|
|
@Gruzzberry Reviewed at |
jotitadev
left a comment
There was a problem hiding this comment.
Linux run of head 53a9b2d3b9, merged (--no-commit) onto main 6a691f69ee. Ubuntu 26.04 (kernel 7.0), GCC 15.2.0, CMake 4.2.3, Ninja, Release, BUILD_TESTING=ON, i7-8700.
guest_socket_pair: passes 3/3.- Full build ok. Related subset
guest_socket|guest_udp|guest_tcp|guest_poll|guest_net|guest_select|guest_kernel_fcntl: 35/35. public_headers: 65/65.- Red: with
Udp.cppreverted tomainand the new test kept,guest_socket_paircrashes (SEGFAULT) 3/3. - Udp.cpp stack:
main+ #13695 + #13738 + #13742 + #13752 + #13756 merged in that order (all touchUdp.cpp) merges cleanly; full build ok, the five focal tests (guest_socket_pair,guest_socket_options,guest_udp,guest_poll,guest_kernel_fcntl) pass 3/3, the socket subset 35/35 andpublic_headers65/65.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
…nter Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…or registration throws Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
53a9b2d to
0d2ae1a
Compare
|
@oneandonlydean thanks, fixed in
Tests: |
|
Checked the copyout order against FreeBSD 11.4 |
What
socketpairwith a result pointer the guest cannot write crashed the host: a pointer such as0x10was accepted by the guest-arena write guard and the final store tosvfaulted. FreeBSD 11.4'ssys_socketpairrunskern_socketpairfirst, so every argument error keeps its source order, thencopyouts the two descriptors; if the copyout fails it closes both withkern_closeand returnsEFAULT.The pair is now created and installed as before, and the two numbers are written with
GuestCopyOut_nid_no_patch. If that fails, both descriptors are closed and the call fails withEFAULT. A null pointer takes the same path (it used to be rejected before anything was created), so the lowest free descriptor numbers are the same afterwards, as on FreeBSD. Close-on-exec registration happens only after the copyout succeeds. Argument errors (family, type, protocol) still win over a bad pointer.Tested
Windows 11 (10.0.26200), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
-DBUILD_TESTING=ON, on currentmain.guest_socket_pair: new checks for0x10with a stream and a datagram pair, a mapped page with no access, ansvthat starts 4 bytes before such a page (secondintunreadable), all giving-1withEFAULT, and a check that a failed call withSOCK_CLOEXECreleases both numbers (the next pair gets the same numbers). Onmainthe test crashes with a write fault at0x10; with this change it passes, three runs out of three.pr_overlap_encoding,agc_host_import_cut_lifetimeandagc_driver_depth_plane_partial_store, which fail onmainin this environment too, plusvulkan_validation_gate_reportsandcheck_compile_test_windows_gcc_response_text_mode_is_not_reinterpreted, which fail here because the Windows Store Python launcher path cannot be read (OSErroronpython.exe) and touch nothing in this change.guest_libc_cnd_timed_waitandguest_timed_wait_cpufailed in the parallel run under load and passed alone.python tools/check_conventions.py --base upstream/main: passes.Overlaps
tools/pr_overlap.pyfound no confirmed overlap. It could not compareUdp.cppandGuestSocketPair.cppagainst #5021, #7088, #8605, #9713, #10645, #12682, #12688, #12700 and #12965 because those conflict withmainthemselves; I read their diffs and none changessocketpair_nid_postfix(#8605, #12682, #12688, #12700 and #12965 only call it in tests).Checklist
main; no other open PR implements the same functionNotImplemented_nid_no_patch); no silent stubs added.mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code