fix(libSceAgc): read sceAgcLinkShaders' and sceAgcAcbSetWorkloadsActive's guest pointers through checked copies #23397
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23397"
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 milescoviello on 2026-11-19T00:14:54Z.
What
Folds my two open
libSceAgcguest-copy PRs into one, as asked on #23161. Each commit is the original PR's change with its message, and the two debt entries are merged into one fragment. #22057 and #22495 will be closed with a link here.sceAgcLinkShaders(#22057). It read the vertex and pixel shader headers through the guest pointers and stored the 34 context and 3 primitive registers straight into the caller's outputs, so an unmapped output or shader pointer crashed the host.GuestCopyIn_nid_no_patchfirst.GuestCopyOut_nid_no_patchbefore the pipeline is committed. If the primitive registers cannot be written, the context registers are restored.GRAPHICS5_ERROR_INVALID_SHADER_PROGRAM, the result for a null output or vertex shader, witherrnopreserved. Nothing is published.sceAgcAcbSetWorkloadsActive(#22495). It read the workload ids straight through the guest pointer.GuestCopyIn_nid_no_patch.DcbState/src/Workload.cpp; this PR doesn't edit that file.Results for valid pointers are unchanged. The special-register and semantic tables the shader headers point to are still read directly; the debt fragment says so.
Tested
Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release,
-DBUILD_TESTING=ON, onc6853f2859(onmain973026d9b0):guest_shader_linkgains four unmapped (0x10) calls: context output, primitive output, vertex shader, pixel shader. Each returnsGRAPHICS5_ERROR_INVALID_SHADER_PROGRAM, keepserrnoat 71 and leaves both outputs byte-for-byte unchanged.agc_commandsgains one check: ids at0x10with a count of 2 return null and leave the buffer's cursor where it was.agc_commands,agc_initializationandguest_shader_linkpass, 3 runs.main'sLinkShaders.cpporControl.cppand the new checks, the tests end infatal SIGSEGV (code 1) at address 0x0000000000000010.Windows 11 VM (GeForce GT 1030, WinLibs GCC 16.2.0 POSIX UCRT, Ninja, Release):
agc_commands,agc_initializationandguest_shader_linkpass, 3 runs, onc6853f2859.c4c8723a96: theagc,guest_video_out,video_outandpad_sdltests pass 2050 of 2054 on bothmainand the PR, with the sameVUID-messages.Both:
git merge-treeagainstmaind89f26516cis clean. #22417'sCommands.cpphunk adds a test function away from this PR's line.tools/check_conventions.pypasses on the branch and this body.tools/debt_fold.py --checkreports nothing for the fragment.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-23T06:09:04Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
c6853f285966c5f0f61a258a22c4087365804438. No commands or tests were run. I read the prepared description, commits, diff, manifest, README, and full text of all five changed files; I also read the checked-copy implementations and shader helper functions relevant to the changes.files.jsonwas not available as a review document; the manifest and review README list all five changed files as included.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author-reported test runs and negative controls were not independently run. Console behavior for unreadable guest pointers is explicitly unmeasured in the debt fragment. The shader headers are copied safely, but the special-register and semantic tables they reference remain directly read as documented.
To get this to a good state
Nothing is required.