Repository navigation
fix(libkernel): look up the descriptor of read, write, pread and pwrite before their buffer and offset - #8663
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.
|
|
Independent Windows run of this PR. Environment: Windows 11 10.0.26300, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON. I built only the test targets involved. Results:
Not run: other platforms, the rest of the 18 tests listed in the description, the full repository CTest, and any title or console run. AI-assisted: yes |
…te before their buffer and offset A null buffer, or for pread and pwrite a negative offset, was answered with EFAULT or EINVAL before the descriptor was looked at, so a descriptor that is not open (EBADF) or a pipe (ESPIPE) was hidden. FreeBSD 11.4 sys_generic.c looks the descriptor up first (kern_readv, kern_preadv: fget, then the seekable check, then the offset) and only reaches the buffer when it copies. The check runs only when the buffer or offset is invalid, so a normal transfer costs nothing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
77ec6f1 to
c2b9249
Compare
|
Linux data point for AI-assisted (Claude Code). |
|
Checked the descriptor-first order against FreeBSD 11.4 |
What
New helpers
PositionedArgumentErrorandTransferArgumentError(Stdio.cpp) run only when the buffer is null or the offset is negative: EBADF if the descriptor is not open, ESPIPE for a socket or pipe, EINVAL for a negative offset, otherwise EFAULT. Used bypread,pwrite,read,_read,write,_write,sceKernelPread,sceKernelPwrite(both host variants),sceKernelReadandsceKernelWrite. The size limit and the iovec calls are not changed.Fixes #8662
git merge-treeagainstupstream/mainand against the open socket and libkernel PRs #8499, #8492, #8474 and #8463 is clean;pr_overlapwas not run.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on
upstream/main+ head77ec6f13e2:guest_filesystem(new cases) fails without the changes toStdio.cppandOpen.cppand passes with them.read,write,pread,pwriteor thesceKernelvariants with a null buffer or a negative offset and are built on Windows all pass, 18 of 18:guest_posix_scalar_io,guest_kernel_sys,guest_posix_filesystem,guest_apr_read_*,guest_filesystem,guest_aio,guest_sendfile,guest_shm_open,guest_kernel_app_archive_*,guest_dup,guest_file_vector. No test line had to be changed.GuestDirectoryEntries.cpp:144/145and the NamedShm tests are Linux-only and were read in the code, not run.python tools/check_conventions.py --base upstream/main: passes.fstatthere), 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