Repository navigation
fix(libkernel): fail readv and writev on a socket with EFAULT for an unusable buffer - #17248
Merged
oneandonlydean merged 1 commit intoNov 12, 2026
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.
|
Contributor
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
gabichuuuuu
reviewed
Nov 8, 2026
gabichuuuuu
left a comment
Contributor
There was a problem hiding this comment.
Windows run of head fa596cd2ab, merged onto main 286b14d2f7 in one tree with 47 other small open PRs that touch different files. Setup: Windows 11, WinLibs GCC 15.2 r7 (x86_64-ucrt-posix-seh, the CI toolchain), Release, BUILD_TESTING=ON.
guest_socket_read_writewith--repeat until-fail:5: 5 / 5 pass.- Negative control, with
main'sUdp.cppand this PR's test: 5 / 5 runs fail.
…unusable buffer Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Gruzzberry
force-pushed
the
fix/socket-readv-writev-efault
branch
from
November 12, 2026 17:46
fa596cd to
6be7099
Compare
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
readvandwritev(andsceKernelReadv,sceKernelWritev) on a guest socket gathered the caller's buffers with a rawmemcpyfrom, and scattered the received bytes with a rawmemcpyto, the guestiovecbases. The iovec array itself is already checked, but a base such as0x10or a read-only page crashed the host. FreeBSD 11.4'skern_writevandkern_readvmove the data withuiomove, so an unusable buffer fails withEFAULT(sosendandsoreceivereturn the error fromuiomove).GuestSockets::Writevnow gathers withGuestCopyIn_nid_no_patchandGuestSockets::Readvscatters withGuestCopyOut_nid_no_patch, and each returnsEFAULT(SCE_KERNEL_ERROR_EFAULTfrom thescecalls) when a copy fails. Awritevwhose gather fails sends nothing. Areadvhas already taken the bytes off the socket when the scatter fails, as in the kernel, wheresoreceivehas dequeued the data whenuiomovefaults, so those bytes are lost. The null-base check, the length checks and the zero-length cases are unchanged. There is no debt entry because the errors follow the source.Tested
Windows 11 (10.0.26200), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
-DBUILD_TESTING=ON, onmainf5fe807.guest_socket_read_write: new checks thatsceKernelWritevandwritevon a connected TCP socket fail withSCE_KERNEL_ERROR_EFAULTandEFAULTfor a base of0x10, that a vector with a usable first buffer and an unusable second one sends nothing (the peer is not readable), and thatreadvwith a base of0x10fails withEFAULTafter the 8 bytes sent beforehand (the socket is empty afterwards). WithSocket/src/Udp.cppreverted tomainthe test crashes (SegFault); with this change it passes, three runs out of three.python tools/check_conventions.py --base upstream/main: passes.Overlaps
cancel blocked POSIX writes with partial progress) and feat(libkernel): support deferred cancellation in POSIX accept #12965 (support deferred cancellation in POSIX accept) replace the block aroundGuestSocketReadGuest_nid_no_patch,GuestSockets::Read,Write,ReadvandWritevinSocket/src/Udp.cpp, where this PR changes two lines each inReadvandWritev. Both already conflict withmain, sopr_overlap.pydid not compare them. This PR goes first and they rebase onto it (two lines); asked on both.Udp.cppandGuestSocketReadWrite.cpp, in other functions (SendError,WaitForTransfer,sendandrecv, socket state) and not inReadvorWritev; fix(libkernel): wait for the rest of a MSG_WAITALL stream receive in the guest layer #11896, fix(libkernel): fail sends and receives on a socketpair end whose peer closed on Windows #15785, fix(libSceNet): keep close-on-exec for fcntl on a sceNetSocket socket as FreeBSD does #16826, feat(libkernel): support kevent read and write events on regular files #7088 and feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021 touchUdp.cppelsewhere.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