Repository navigation
fix(libkernel): return EFAULT from sceKernelRead and sceKernelWrite for a null buffer - #7025
Merged
oneandonlydean merged 1 commit intoOct 17, 2026
Conversation
… null buffer read and write already fail with EFAULT for a null buffer and a non-zero length and treat a zero-length null buffer as empty. The sceKernel entry points threw std::invalid_argument for both. They now do the same as read and write. 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.
|
11 tasks done
Contributor
|
Windows cross-validation of the whole series (stacked on main 5f61879) is in #7023 (comment): this PR's test passes 3/3, and with only this PR's source reverted it fails with main's throw. Suite, conventions and two title runs show no regression. Written with Claude Code assistance (validation by a subagent, reviewed in this session). |
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
sceKernelReadandsceKernelWritethrewstd::invalid_argumentfor a null buffer, even with a byte count of 0. The POSIXread,_read,writeand_writeinStdio.cppalready handle a null buffer: a non-zero count fails withEFAULT, and a zero count is treated as an empty buffer, so the descriptor is still checked.The
sceKernelentry points now do the same:0x8002000efor a null buffer with a non-zero count, otherwise a zero-length transfer on the descriptor (0, or0x80020009for a descriptor that isn't open). The guest socket path is unchanged.This is the same approximation the POSIX wrappers use. FreeBSD looks the descriptor up first and fails with
EFAULTonly when it copies through the buffer. So on a closed descriptor it reportsEBADF, and a read at end of file returns 0.I don't know of a title that hits this. I found it while going through the argument throws in libkernel.
Tested
Ubuntu 24.04, GCC 13.3, Release, on
main6a32550.guest_posix_scalar_io: new checks forsceKernelReadandsceKernelWritewith a null buffer: a count of 1 gives0x8002000e, a count of 0 gives 0, and a count of 0 on descriptor -1 gives0x80020009. Withmain'sOpen.cppthe test aborts on the first of these (the throw). With this change it passes 3 of 3.ctest -R '^guest_|libc': 403 of 403 pass, with this and my other small libkernel argument fixes from today applied together.tools/check_conventions.pypasses.tools/pr_overlap.pyfinds no conflicting lines. It couldn't compare against feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, test: organize library tests and label CTest suites #6044 and fix(libkernel): preserve directory identity across Windows renames #6228, which conflict withmain. None of their diffs touchessceKernelReadorsceKernelWrite.main's behaviour. (series run by @screamm)Not checked: macOS, a console.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code