Repository navigation
fix(libc): write std::__sce_v2::filesystem::_Current_get's path through a checked guest copy - #22938
Conversation
…gh a checked guest copy std::__sce_v2::filesystem::_Current_get stored the sandbox root "/" and its terminator through the caller's pointer, so an unmapped or read-only buffer crashed the host. Both bytes are now written with one GuestCopyOut_nid_no_patch, and the function returns false, keeping errno, when the buffer can't be written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against a725a55a9c:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_sce_v2_filesystem_testsbuilt cleanly. - CTest (
guest_sce_v2_filesystem):1/1 Test #1062: guest_sce_v2_filesystem .......... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libc/src/VersionedFilesystem.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #1062: guest_sce_v2_filesystem ..........***Exception: SegFault 0.41 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- Verified that GuestCopyOut_nid_no_patch is correctly used with target, root, and sizeof(root) (2 bytes including null terminator), safely handling unwritable guest pointers without host crash.
- Verified that errno is preserved across GuestCopyOut_nid_no_patch via savedErrno, maintaining expected libc errno state on error.
- Verified that the technical debt fragment in docs/dev/debt/changes/fix-libc-sce-v2-current-get-guest-copy.md follows the required schema, correctly documents the fallback, and passes debt check tools.
- Verified that the unit test in core/libs/tests/GuestSceV2Filesystem.cpp exercises both the valid buffer path and the unwritable buffer path (0x10) without regressions.
- Verified compliance with AGENTS.md: no illegal comments, no hardcoded magic game paths, clean conventions check, and clean git diff.
Looks Good To Me
|
Tested head Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
Whole batch: the full This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code) |
|
Thanks @kiwe147 for including this one in the batch. The |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The change uses the checked guest copy for the two output bytes, returns its failure result, and preserves errno; the inspected source supports merging.
What I ran
Reviewed head a725a55a9c1eec709ecdb9b95877b31d0818c602. No commands or tests were run; repo_read.py was unavailable as an executable tool here. The author reports tests, but those were not run in this review.
Read the prepared description, commits, manifest, diff, all three changed files, and the relevant GuestCopyOut_nid_no_patch implementation in General.cpp. No changed files were excluded.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | All changed files and copy helper read |
| Tests | not run | Author reports runs on Windows and Linux |
| Negative control | not run | Author reports a Linux negative control |
Findings
Blocking
None.
Non-blocking
None.
Not verified
Runtime behavior and reported test runs were not independently verified. No files from files.json were available to inspect; the manifest lists three changed files, and all three were read from the pinned head.
To get this to a good state
Nothing is required.
What
std::__sce_v2::filesystem::_Current_getstored the sandbox root/and its terminator through the caller's 260-byte buffer, so an unmapped or read-only buffer crashed the host.Changes:
GuestCopyOut_nid_no_patch.false, the function's existing failure result, anderrnois kept.The result for a valid buffer is unchanged. It still writes exactly two bytes, as the existing check pins.
Tested
Windows 11 VM (GeForce GT 1030, WinLibs GCC 16.2.0 POSIX UCRT, Ninja, Release):
guest_sce_v2_filesystemgains an unmapped buffer (0x10), which returnsfalse.guest_sce_v2_filesystempasses, 3 runs, ond55b17a0f1.mainwith only the new check (eef55a4b23) endsguest_sce_v2_filesystemin an access violation (0xc0000005).git merge-treeagainstmainis clean. fix(libc): keep UNC host paths on their share on Windows #19652 also editsVersionedFilesystem.cpp, not this function;git merge-treeof this branch with it is clean. No open PR edits the test file.tools/check_conventions.pypasses on the branch and this body.tools/debt_fold.py --checkreports nothing for this fragment.Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release,
-DBUILD_TESTING=ON:guest_sce_v2_filesystempasses, 3 runs, ona725a55a9c(this PR's head).main's source file endsguest_sce_v2_filesystemin SIGSEGV at address0x10.a725a55a9c, applied with other PRs ontomainfd4aeed483(one combined tree, not this PR alone), Windows 11, WinLibs GCC 15.2.0 r7, Release, no validation layer:guest_sce_v2_filesystemandguest_sce_v2_filesystem_callspass on an NVIDIA GeForce RTX 3080 (driver 621.24).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)