fix(libSceAudiodec.native): guard guest write checks with HostWrite #28806
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28806"
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 NobleBrains on 2026-12-03T19:12:13Z.
What
libSceAudiodec.nativechecked guest output pointers withGuestWritable_nid_no_patchoutside aGuestArena::HostWritescope, so a page the emulator has write-protected could be taken for an invalid pointer.WritableGuest, whichsceAudiodecRegisterCodecuses for the lock and flag checks, opensGuestArena::HostWritebefore the writability check and returns false whenguard.Open()fails or the pointer is null.sceAudiodecGetContextusesWritableGuestinstead of the bare check, which also keeps the caller'serrno. Error codes are unchanged.core/libs/tests/GuestAudiodecNative.cppchecks with aHostWritehook that both functions open the guard for valid, unmapped, null and read-only pointers, and thaterrnois preserved.Tested
Linux (Distrobox, GCC 13.3):
ctest --test-dir build -R 'guest_audiodec_(ajm_context|native)'passed (3/3). With the fix removed,guest_audiodec_nativefails at "GetContext unmapped opens HostWrite".python3 tools/check_conventions.pypassed. Windows: not tested. No title was run.python3 tools/pr_overlap.py --base main --branchreports only the include lines ofGuestAudiodecNative.cpp, shared with #28599.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
https://claude.ai/code/session_01GtiotZ92uvDBp76KjCvueG
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T19:19:28Z.
Review: COMMENTED
The shared codec registration drops the new guard before calling
scePthreadRwlockWrlock. On the first use of a zero-initialized rwlock,RequireRwlockinstalls the newly allocated handle with an atomic store to the guest slot. That store still needs the host-write scope, so a valid tracked context can pass the preflight and then encounter a protected page during initialization. Please keep the lock slot writable through its use, or make initialization take its own guest write scope. The hook test checks the preflight calls. A zero-initialized lock in a tracked guest mapping would also exercise the write itself.The integrated
guest_audiodec_nativefixture passed on Linux with0d701f9411applied. The tracked rwlock case above is from source inspection.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T19:21:16Z.
Review: COMMENTED
Actionable comments
782abdbf-5535-493a-9be5-871309806781Reviewing files that changed from the base of the PR and between
a9cbd48cb0and0d701f9411.core/libs/prx/libSceAudiodec.native/Export.cppcore/libs/tests/GuestAudiodecNative.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T21:46:45Z.
Review: APPROVED
Reviewed — looks good
The implementation is sound at head
0d701f94117f22e6296bf2d14f7db7d7ef7ead43; no required changes block merging.What I ran
Inspected the changed hunks and relevant callers through
repo_read.pyat the exact head above. No tests or build commands were run.Results
Negative control
Not run in this review. The description reports that removing the fix makes
guest_audiodec_nativefail; that result was not independently verified.Findings
Blocking
None.
Non-blocking
sceAudiodecRegisterCodec;sceAudiodecGetContextis tested with valid, unmapped, and null pointers, but not a read-only pointer. Consider adding that case to directly cover its new validation path. See the changed test cases at GuestAudiodecNative.cpp and the read-only case.Sources
WritableGuestopensHostWrite, checks writability, and restoreserrno;sceAudiodecGetContextnow uses it: Export.cpp, GetContext.Not verified
Tests, build, Windows execution, and console behavior were not run. The author-reported Linux test and convention-check results were not independently verified. Both changed files listed as reviewed were inspected at their changed hunks;
files.jsonlists no excluded files.To get this to a good state
Nothing is required. Optional: add a read-only-pointer case for
sceAudiodecGetContext.Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T12:50:39Z.
Review: APPROVED
Verified on Windows 11 with WinLibs GCC 15.2.0 r7 (Release). I used a tree at
main63b98e5bf8(plus two unrelated commits of mine in libc and a LibreSSL test), with this PR applied together with #28881, #28810, #28806, #28776 and #28781, which touch separate files. I ran everystrict_nid_filter,guest_audiodec*,guest_np_manager*,guest_np_reachabilityand HarfBuzz test (31): all pass before the change, and all pass in 3 of 3 runs with it.That fills the "Windows: not tested" gap. Negative control, with
libSceAudiodec.native/Export.cppas onmainand the new test kept:guest_audiodec_nativeaborts with "GuestAudiodecNative: GetContext unmapped opens HostWrite".guest_audiodec_ajm_contextand_pointerpass before and after.Not run: a title.
AI-assisted: yes (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.