fix(libkernel): return EFAULT for unusable JIT shared-memory pointers #14497
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14497"
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 fogydes on 2026-11-01T15:16:13Z.
What
Guard the JIT shared-memory output and in/out pointer copies. Creation and alias creation close the newly registered descriptor if fdOut cannot be written. Mapping reads startOut through checked copyin and rolls back the mapping if copyout fails. EFAULT on unusable memory is a documented host-safety fallback, not a console measurement.
Preserve g_jitLock through descriptor lookup, permission checks, duplication and DoMapShared so concurrent close cannot invalidate or reuse the descriptor before use. Release that lock before guest copyout and rollback. Rebased onto current main
cacaa4a5ec; only Jit.cpp, the focused regression test and its debt entry differ.Tested
f86d7e4988(0.85s).cacaa4a5ecpassed.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:59:10Z.
Review: COMMENTED
Reviewed — no blocking findings
The three JIT shared-memory calls now copy their arguments in and out with
GuestCopyIn/GuestCopyOutand return EFAULT for an unreadable or unwritable pointer. On the two failure paths after a descriptor is created, the code closes the new descriptor, andclose_nid_postfixforgets the JIT entry (Stdio.cppline 811), so no stale registry entry is left. The map path unmaps the new mapping when the copy-out fails. The guest test did not run hosted: its CTest run has one tool case.What I ran
d255b6d1840eb9bedadab87811964920d2b2bc1f; basef2d874c1fdccf781c0fa5d86619bb5dd8894b958. 3 files, +53/-23:core/libs/prx/libkernel/DirectMemory/Jit.cpp,core/libs/tests/GuestJitSharedMemory.cpp(+10) anddocs/dev/debt/libkernel.md(+1). The test is registered asguest_jit_shared_memory_tests(libkernel/CMakeLists.txtline 1580).Jit.cppdiff for create, alias and map, and the close path that forgets the descriptor (File/src/Stdio.cpplines 796-811 andForgetJitSharedMemoryatJit.cppline 178).guest_jit_shared_memorywas not in the run.Results
close_nid_postfixforgets the entry (Stdio.cppline 811)sceKernelMunmapundoes the mapping (read)guest_jit_shared_memory(hosted)Read-only check output
Precheck was not run: no PR-head code is run here. Conventions: passed. Hosted:
gh api repos/boykopovar/AnyPS5/commits/d255b6d1840eb9bedadab87811964920d2b2bc1f/check-runs.Negative control
Not run here. A negative control needs a build, and code from this head is not run here.
Findings
Blocking
None.
Non-blocking
None.
Sources
github.com/boykopovar/AnyPS5@d255b6d184/core/libs/prx/libkernel/DirectMemory/Jit.cppgithub.com/boykopovar/AnyPS5@f2d874c1fd/core/libs/prx/libkernel/File/src/Stdio.cpp (L796-L811)github.com/boykopovar/AnyPS5@d255b6d184/core/libs/tests/GuestJitSharedMemory.cppNot verified
To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T10:12:40Z.
Review: APPROVED
Reviewed — looks good
The inspected changes handle invalid guest pointers and descriptor cleanup coherently; the reported build and regression run were not independently reproduced.
What I ran
Reviewed head
f86d7e4988c4d56a39df47af222fd0a0e8d03ec4using the prepared diff and pinned reader. No build or test command was run. The PR description reports a Windows 11 x64 build andguest_jit_shared_memorypassing; these are author-reported results.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read the full changed
Jit.cppandGuestJitSharedMemory.cpp, and the changed entry at the end ofdocs/dev/debt/libkernel.md. The prepared diff, description, commits, and manifest were read. The reported build and test were not rerun; console behavior was not measured.To get this to a good state
Nothing is required.