fix(libSceAgc): validate suspend and fused-size inputs before use #17742

Closed
tanmayvdani wants to merge 2 commits from upstream-pr/17742 into main
tanmayvdani commented 2026-11-09 13:50:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tanmayvdani on 2026-11-09T13:50:32Z.


What

Validate sceAgcSuspendPointAndCheckStatus and sceAgcGetFusedShaderSize_0080 inputs before use: reject unreadable/null pointers with APS5_INVALID_ARG_EX, validate the shader-halves pair before touching the output, and store the fused-size alignment as a 32-bit value at +8 preserving +12. Adds agc_suspend_status tests. Also drops the now-redundant libSceAgcVsh sceAgcSuspendPointAndCheckStatus_nid_no_patch stub: the shared Suspend.cpp source already provides the real export under NID b+fis+WZ3Ig, and keeping both double-exports the NID, which the Windows nid_patcher rejects (same treatment as d3189e41fd).

Tested

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -V -R "agc_suspend_status|agc_platform_tests|agc_shader_fusion", same machine and GPU on main (eb3839d4f3) and on this branch. Main: 2/2 passed (agc_platform_tests, agc_shader_fusion). This branch: 3/3 passed (adds agc_suspend_status). Neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS; the loader log confirms Insert instance layer "VK_LAYER_KHRONOS_validation" with 0 load failures; VUID- count is 0 on both, so the change adds no new validation errors. Full logs are attached in a comment below. python3 tools/check_conventions.py --base origin/main passes; python3 tools/pr_overlap.py reports no shared lines with #5021 (disjoint CMake hunk) or #14212 (whitespace-only) -- see comment.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3060 (driver 610.88), Windows 11 (10.0.26200), Vulkan loader 1.4.341 with VK_LAYER_KHRONOS_validation 1.4.335
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5224944246 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17742). Originally posted by [tanmayvdani](https://github.com/tanmayvdani) on 2026-11-09T13:50:32Z. --- ### What Validate `sceAgcSuspendPointAndCheckStatus` and `sceAgcGetFusedShaderSize_0080` inputs before use: reject unreadable/null pointers with `APS5_INVALID_ARG_EX`, validate the shader-halves pair before touching the output, and store the fused-size alignment as a 32-bit value at +8 preserving +12. Adds `agc_suspend_status` tests. Also drops the now-redundant `libSceAgcVsh` `sceAgcSuspendPointAndCheckStatus_nid_no_patch` stub: the shared `Suspend.cpp` source already provides the real export under NID `b+fis+WZ3Ig`, and keeping both double-exports the NID, which the Windows `nid_patcher` rejects (same treatment as `d3189e41fd`). ### Tested `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -V -R "agc_suspend_status|agc_platform_tests|agc_shader_fusion"`, same machine and GPU on `main` (`eb3839d4f3`) and on this branch. Main: 2/2 passed (`agc_platform_tests`, `agc_shader_fusion`). This branch: 3/3 passed (adds `agc_suspend_status`). Neither log contains `was not found but was requested by env var VK_INSTANCE_LAYERS`; the loader log confirms `Insert instance layer "VK_LAYER_KHRONOS_validation"` with 0 load failures; `VUID-` count is 0 on both, so the change adds no new validation errors. Full logs are attached in a comment below. `python3 tools/check_conventions.py --base origin/main` passes; `python3 tools/pr_overlap.py` reports no shared lines with #5021 (disjoint CMake hunk) or #14212 (whitespace-only) -- see comment. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3060 (driver 610.88), Windows 11 (10.0.26200), Vulkan loader 1.4.341 with VK_LAYER_KHRONOS_validation 1.4.335 - [x] AI-assisted: yes
MarcZX10 commented 2026-11-22 11:45:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T11:45:45Z.

Review: COMMENTED


Reviewed — no blocking findings

The prepared change is internally consistent in the code reviewed, but the suspend signature and firmware behavior remain unverified, so a formal approval is not justified.

What I ran

Reviewed head 1c3c2f0f90e2d2d5c5e03adf9f5fd2bc7a17d9ca using the prepared diff and pinned repository reader repo_read.py. No tests or build commands were run; the test results in the description are author-reported.

Results

Check Result Note
Diff and changed code passed Reviewed included changed files
Automated tests not run Reported results not independently verified
Firmware behavior not run Suspend contract is untraced

Findings

Blocking

None.

Non-blocking

  • sceAgcSuspendPointAndCheckStatus accepts any readable one-byte pointer, then maps every std::exception from the driver suspend to GRAPHICS5_ERROR_SUSPEND_DISALLOWED. The code and debt note both say the signature and firmware behavior are unverified. Keep this contract explicitly provisional until it can be checked against firmware or console behavior. Changed line: core/libs/prx/libSceAgc/Misc/src/Suspend.cpp:39.

Not verified

  • No test/build execution; the Vulkan and convention-check results in the PR description were not independently run.
  • Firmware or console behavior for the suspend parameter, result code, and fused-size output ordering/write shape.
  • The deleted file core/libs/prx/libSceAgc/Export.cpp has no head text to read. All other manifest entries marked included were read; no excluded-file inventory was available in the prepared artifacts.

To get this to a good state

Nothing is required. Optional: confirm the suspend contract against firmware or console evidence and update the implementation and debt note if needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012041426 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17742#pullrequestreview-6012041426). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T11:45:45Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The prepared change is internally consistent in the code reviewed, but the suspend signature and firmware behavior remain unverified, so a formal approval is not justified. ## What I ran Reviewed head `1c3c2f0f90e2d2d5c5e03adf9f5fd2bc7a17d9ca` using the prepared diff and pinned repository reader `repo_read.py`. No tests or build commands were run; the test results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Reviewed included changed files | | Automated tests | not run | Reported results not independently verified | | Firmware behavior | not run | Suspend contract is untraced | ## Findings ### Blocking None. ### Non-blocking - `sceAgcSuspendPointAndCheckStatus` accepts any readable one-byte pointer, then maps every `std::exception` from the driver suspend to `GRAPHICS5_ERROR_SUSPEND_DISALLOWED`. The code and debt note both say the signature and firmware behavior are unverified. Keep this contract explicitly provisional until it can be checked against firmware or console behavior. Changed line: `core/libs/prx/libSceAgc/Misc/src/Suspend.cpp:39`. ## Not verified - No test/build execution; the Vulkan and convention-check results in the PR description were not independently run. - Firmware or console behavior for the suspend parameter, result code, and fused-size output ordering/write shape. - The deleted file `core/libs/prx/libSceAgc/Export.cpp` has no head text to read. All other manifest entries marked included were read; no excluded-file inventory was available in the prepared artifacts. ## To get this to a good state Nothing is required. Optional: confirm the suspend contract against firmware or console evidence and update the implementation and debt note if needed.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!17742
No description provided.