fix(libkernel): look up the descriptor of read, write, pread and pwrite before their buffer and offset #8663
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8663"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T20:17:56Z.
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
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T20:31:24Z.
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.
core/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/tests/GuestFilesystem.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libkernel/File/src/Stdio.cppImported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-20T22:02:46Z.
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:
guest_filesystem,guest_posix_scalar_io,guest_aio,guest_dupandguest_sendfileall pass (5/5).File/src/Stdio.cppandFile/src/Open.cpp) with their base versions, then rebuilt.guest_filesystemfails with exit 0xc0000409, matching the description. I restored the PR's files afterwards.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
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T03:40:03Z.
Linux data point for
c2b92498b5(WSL2, Ubuntu 24.04, GCC 13.3, Release,-j4; a virtualised kernel, not bare-metal Linux): the descriptor-order test family (guest_filesystem and the tests that call read/write/pread/pwrite) pass on Linux (17 of 17). This replaces the "Linux not tested" line in the description for this head. Not tested: macOS.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T18:36:25Z.
Checked the descriptor-first order against FreeBSD 11.4
kern_preadv/dofileread(EBADF, ESPIPE, EINVAL for a negative offset, EFAULT last), all twelve call sites, and the newguest_filesystemcases (they expect EBADF/ESPIPE wheremainreturned EFAULT/EINVAL; @cadenasynyster also confirmed them failing on baseline on Windows); merged.