fix(apr): reject submissions beyond buffer capacity #5553

Closed
cookie42073-cmd wants to merge 1 commit from upstream-pr/5553 into main
cookie42073-cmd commented 2026-10-13 23:43:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cookie42073-cmd on 2026-10-13T23:43:32Z.


What

Hi, this is Blazing Cook.

APR submission passes the recorded length to the executor and queued copy without checking the object's capacity. A buffer containing two valid writes, with its declared capacity reduced to the first write, still executes both. This checks the original descriptor before _submit, so all three submission exports reject an offset beyond capacity without executing commands, consuming an ID or changing the result/ID outputs.

This follows up on the remaining submission-capacity check from item 2 of #3321. The error uses the exports' existing -1/guest EINVAL path. Native PS5 behavior for a corrupted opaque buffer remains unverified and is recorded in technical debt. No title unblock is claimed.

Tested

Windows x64, MinGW-w64 GCC 15.2.0, Release, Tracy disabled.

Tested base: d1670009fbfdfe57f8f26ee09ced77fe6b18c2ca. Fix: 0081a8bd9277973ed09034521c574daefc4ec0d5.

  • Before/after: the new registered guest_ampr_markers regression fails on the upstream APR implementation because it returns success and executes both writes; it passes with the two submission guards. The test covers all three exports with an idle queue and with a blocked command ahead, unchanged outputs/backing/object fields, no consumed submission ID, exact capacity and empty buffers.
  • Full default build and libs target; seven selected CTest tests: guest_ampr_markers, guest_ampr_threads, guest_amm_placement, guest_memory, guest_addresses, guest_mlock, guest_mutex_contention. All passed. The registered APR regression also passed five consecutive runs with normal process exit.
  • Conventions and whitespace checks; independent source and evidence review.

An auxiliary short-process probe intermittently hangs during Windows DLL teardown. The same unchanged valid-submission control reproduces it on d1670009 and the fixed runtime; debugger stacks put it in libkernel CRT detach during LdrShutdownProcess. That separate exit issue is not fixed here. The registered regression completes normally. Linux, native PS5 and commercial games were not tested.

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; silent stubs are documented
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source: none added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes, Codex; reviewed and tested before submission
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4850893000 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5553). Originally posted by [cookie42073-cmd](https://github.com/cookie42073-cmd) on 2026-10-13T23:43:32Z. --- ### What Hi, this is Blazing Cook. APR submission passes the recorded length to the executor and queued copy without checking the object's capacity. A buffer containing two valid writes, with its declared capacity reduced to the first write, still executes both. This checks the original descriptor before `_submit`, so all three submission exports reject an offset beyond capacity without executing commands, consuming an ID or changing the result/ID outputs. This follows up on the remaining submission-capacity check from item 2 of #3321. The error uses the exports' existing `-1`/guest `EINVAL` path. Native PS5 behavior for a corrupted opaque buffer remains unverified and is recorded in technical debt. No title unblock is claimed. ### Tested Windows x64, MinGW-w64 GCC 15.2.0, Release, Tracy disabled. Tested base: `d1670009fbfdfe57f8f26ee09ced77fe6b18c2ca`. Fix: `0081a8bd9277973ed09034521c574daefc4ec0d5`. - Before/after: the new registered `guest_ampr_markers` regression fails on the upstream APR implementation because it returns success and executes both writes; it passes with the two submission guards. The test covers all three exports with an idle queue and with a blocked command ahead, unchanged outputs/backing/object fields, no consumed submission ID, exact capacity and empty buffers. - Full default build and `libs` target; seven selected CTest tests: `guest_ampr_markers`, `guest_ampr_threads`, `guest_amm_placement`, `guest_memory`, `guest_addresses`, `guest_mlock`, `guest_mutex_contention`. All passed. The registered APR regression also passed five consecutive runs with normal process exit. - Conventions and whitespace checks; independent source and evidence review. An auxiliary short-process probe intermittently hangs during Windows DLL teardown. The same unchanged valid-submission control reproduces it on `d1670009` and the fixed runtime; debugger stacks put it in libkernel CRT detach during `LdrShutdownProcess`. That separate exit issue is not fixed here. The registered regression completes normally. Linux, native PS5 and commercial games were not tested. ### Checklist - [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 - [x] Unimplemented paths throw; silent stubs are documented - [x] No notes, investigation files or images added to the repository - [x] New third-party code is a submodule built from source: none added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes, Codex; reviewed and tested before submission
github-actions[bot] commented 2026-10-14 00:22:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T00:22:22Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4953 docs/dev/debt/libkernel.md L13
#5537 docs/dev/debt/libkernel.md L13
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158040624 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5553#issuecomment-6158040624). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T00:22:22Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4953 | `docs/dev/debt/libkernel.md` [L13](https://github.com/boykopovar/AnyPS5/blob/71c71f50b7a42ad1a62b78d9cd24f5a356965557/docs/dev/debt/libkernel.md#L13) | | | | #5537 | `docs/dev/debt/libkernel.md` [L13](https://github.com/boykopovar/AnyPS5/blob/71c71f50b7a42ad1a62b78d9cd24f5a356965557/docs/dev/debt/libkernel.md#L13) | | |
oneandonlydean commented 2026-10-14 02:25:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:25:25Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159501453 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5553#issuecomment-6159501453). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:25:25Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

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!5553
No description provided.