fix(libSceAgc): read and write sceAgcLinkShaders' shaders and outputs through checked copies #22057
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22057"
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-17T03:32:03Z.
What
sceAgcLinkShadersread the vertex and pixel shader headers (type, the semantic counts and pointers) through the guest pointers. Then it stored the 34 context and 3 primitive registers withstd::copyinto the caller's outputs. An unmapped output or shader pointer crashed the host.GuestCopyIn_nid_no_patchbefore any work, and the checks use the copied headers.GuestCopyOut_nid_no_patchbefore the pipeline is committed. If the primitive registers cannot be written, the context registers are restored, so the outputs stay unchanged on failure, as they already do for an invalid shader.GRAPHICS5_ERROR_INVALID_SHADER_PROGRAM, the result for a null output or vertex shader, witherrnopreserved. TheShaderPreparationScopeis not committed, so nothing is published.Every result for valid pointers is unchanged. The special-register and semantic tables the 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:guest_shader_linkgains four calls, witherrnoheld at 71, after the first successful link: an unmapped (0x10) context output, primitive output, vertex shader and pixel shader. Each returnsGRAPHICS5_ERROR_INVALID_SHADER_PROGRAMand keepserrno, and both outputs are byte-for-byte unchanged afterwards. The test's final count of driver ABI calls (7 preparations, 3 mappings, 7 links) is unchanged, so none of the four reaches the driver.guest_shader_linkpasses, 3 runs.main'sLinkShaders.cppand the new calls, it ends infatal SIGSEGV (code 1) at address 0x0000000000000010.git merge-treeagainstmainis clean; no open PR editsLinkShaders.cpporGuestShaderLink.cpp.tools/check_conventions.pypasses on the branch and this body.tools/debt_fold.py --checkreports nothing for this fragment (mainitself fails it on two LibreSSL3 fragments that change the same entry).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)Pull request closed