fix(ampr): validate null command buffer arguments #7625

Merged
voidlakhan merged 3 commits from upstream-pr/7625 into main 2026-10-20 15:36:50 +00:00
voidlakhan commented 2026-10-18 17:47:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by voidlakhan on 2026-10-18T17:47:37Z.


What

Validate null pointers in sceAmprAprCommandBufferConstructor, sceAmprCommandBufferConstructor, sceAmprCommandBufferReset, and sceAmprCommandBufferSetBuffer.

Previously, passing null pointers to these functions could result in invalid memory access due to dereferencing the pointers. These functions now return SCE_KERNEL_ERROR_EINVAL (0x80020016) when their required buffer or state arguments are null.

Add regression tests to TestRejectedArguments() in GuestAmpr.cpp to verify that invalid arguments are rejected.

Tested

  • ninja -C build-full guest_ampr_tests — passed.
  • ctest --test-dir build-full -R "ampr" --output-on-failure — 3/3 tests passed.
  • python tools/check_conventions.py --base upstream/main — passed.
  • git diff --check upstream/main..HEAD — passed.

Checklist

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4911355931 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7625). Originally posted by [voidlakhan](https://github.com/voidlakhan) on 2026-10-18T17:47:37Z. --- ### What Validate null pointers in `sceAmprAprCommandBufferConstructor`, `sceAmprCommandBufferConstructor`, `sceAmprCommandBufferReset`, and `sceAmprCommandBufferSetBuffer`. Previously, passing null pointers to these functions could result in invalid memory access due to dereferencing the pointers. These functions now return `SCE_KERNEL_ERROR_EINVAL` (`0x80020016`) when their required buffer or state arguments are null. Add regression tests to `TestRejectedArguments()` in `GuestAmpr.cpp` to verify that invalid arguments are rejected. ### Tested * `ninja -C build-full guest_ampr_tests` — passed. * `ctest --test-dir build-full -R "ampr" --output-on-failure` — 3/3 tests passed. * `python tools/check_conventions.py --base upstream/main` — passed. * `git diff --check upstream/main..HEAD` — passed. ### Checklist * [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)](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md). * [x] No investigation notes, Markdown reports, or images added to the repository. * [x] Generic behavior, not specific to one title. * [x] Depends on: none * [x] Fixes: none * [x] Unblocks: none * [x] GPUs tested: n/a * [x] AI-assisted: yes
github-actions[bot] commented 2026-10-18 18:01:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T18:01:19Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestAmpr.cpp
PR 7081 core/libs/prx/libSceAmpr/Export.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253253196 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7625#issuecomment-6253253196). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T18:01:19Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestAmpr.cpp` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `core/libs/prx/libSceAmpr/Export.cpp` |
voidlakhan commented 2026-10-18 18:07:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by voidlakhan on 2026-10-18T18:07:25Z.


I reviewed the relevant changes in #6044 and #7332.

  • #6044: This PR reorganizes the library test files, including moving GuestAmpr.cpp into the memory directory. My PR only adds null-argument regression tests and validation in libSceAmpr; I have not identified a direct functional overlap.
  • #7332: Its change to GuestAmpr.cpp gates the AMM tests on guest-arena availability, while my change adds assertions in TestRejectedArguments(). These changes affect separate sections of the file.

The overlap checker could not complete its comparisons because the referenced PRs conflict with their base branch. GitHub currently reports this PR as mergeable. I have not identified a direct conflict in the changes reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253319150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7625#issuecomment-6253319150). Originally posted by [voidlakhan](https://github.com/voidlakhan) on 2026-10-18T18:07:25Z. --- I reviewed the relevant changes in #6044 and #7332. * **#6044:** This PR reorganizes the library test files, including moving `GuestAmpr.cpp` into the `memory` directory. My PR only adds null-argument regression tests and validation in `libSceAmpr`; I have not identified a direct functional overlap. * **#7332:** Its change to `GuestAmpr.cpp` gates the AMM tests on guest-arena availability, while my change adds assertions in `TestRejectedArguments()`. These changes affect separate sections of the file. The overlap checker could not complete its comparisons because the referenced PRs conflict with their base branch. GitHub currently reports this PR as mergeable. I have not identified a direct conflict in the changes reviewed.
adriadam10 commented 2026-10-20 15:39:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T15:39:07Z.


Re-checked after the new head: the code is unchanged, the null guards return SCE_KERNEL_ERROR_EINVAL like the neighbouring exports, the new TestRejectedArguments cases crash on main, and the net docs/dev/debt/libSceAmpr.md change is the single "Unknown function info" line recording the unverified null-argument result (existing entries untouched); merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6294768008 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7625#issuecomment-6294768008). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-20T15:39:07Z. --- Re-checked after the new head: the code is unchanged, the null guards return `SCE_KERNEL_ERROR_EINVAL` like the neighbouring exports, the new `TestRejectedArguments` cases crash on `main`, and the net `docs/dev/debt/libSceAmpr.md` change is the single "Unknown function info" line recording the unverified null-argument result (existing entries untouched); merged.
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!7625
No description provided.