test(libc): stop the sce v2 thrower cases reading past an 8-byte exception object #10829

Merged
MarcZX10 merged 1 commit from upstream-pr/10829 into main 2026-10-26 07:38:16 +00:00
MarcZX10 commented 2026-10-25 03:18:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T03:18:42Z.


What

guest_sce_v2_exceptions read 16 bytes of every caught object in its inspection hook, but the plain throwers (such as _Xbad_alloc) allocate only sizeof(void*) bytes for the exception object. AddressSanitizer reports a 16-byte heap-buffer-overflow read in SceV2Inspect. The thrower cases only compare the type name and message, so the hook now copies the pointer size for them and restores the full size afterwards. Test-only change, one commit; no product code changes.

Tested

Linux x86-64 (Debian 12, GCC 12), ASan+UBSan build. On current main guest_sce_v2_exceptions fails with heap-buffer-overflow ... READ of size 16; with this change it passes. python3 tools/check_conventions.py --base upstream/main --head HEAD and git diff --check upstream/main pass. Windows, macOS and hardware were not run.

Rebase validation (2026-10-25)

Rebased the single test-only commit onto current main 451e21f4aea0e59ff60f2df0056184cc3c41d320; it applied cleanly and preserved the MarcZX10 author and committer. git diff --check upstream/main...HEAD and python3 tools/check_conventions.py --base upstream/main --head HEAD pass. The ASan/UBSan runtime test was not rerun after this rebase. Local CMake configuration remains unavailable because the isolated worktree lacks initialized SDL2 and this host lacks XRandR development support; the earlier Linux ASan/UBSan result above is the previously reported run.

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 (not applicable; no third-party code added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5001427242 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10829). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T03:18:42Z. --- ### What `guest_sce_v2_exceptions` read 16 bytes of every caught object in its inspection hook, but the plain throwers (such as `_Xbad_alloc`) allocate only `sizeof(void*)` bytes for the exception object. AddressSanitizer reports a 16-byte heap-buffer-overflow read in `SceV2Inspect`. The thrower cases only compare the type name and message, so the hook now copies the pointer size for them and restores the full size afterwards. Test-only change, one commit; no product code changes. ### Tested Linux x86-64 (Debian 12, GCC 12), ASan+UBSan build. On current `main` `guest_sce_v2_exceptions` fails with `heap-buffer-overflow ... READ of size 16`; with this change it passes. `python3 tools/check_conventions.py --base upstream/main --head HEAD` and `git diff --check upstream/main` pass. Windows, macOS and hardware were not run. ### Rebase validation (2026-10-25) Rebased the single test-only commit onto current `main` `451e21f4aea0e59ff60f2df0056184cc3c41d320`; it applied cleanly and preserved the MarcZX10 author and committer. `git diff --check upstream/main...HEAD` and `python3 tools/check_conventions.py --base upstream/main --head HEAD` pass. The ASan/UBSan runtime test was not rerun after this rebase. Local CMake configuration remains unavailable because the isolated worktree lacks initialized SDL2 and this host lacks XRandR development support; the earlier Linux ASan/UBSan result above is the previously reported run. ### 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 (not applicable; no third-party code added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
THEMANnt commented 2026-10-25 04:03:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T04:03:14Z.

Review: APPROVED


Reviewed 006b5839f52c83cf17174585dd896692adeb1253 against 25c1aa1e79329e0e2957b4fdd731144dad8be724. No actionable findings in this focused review.

Source review: Inspected the complete change, SceV2Inspect/Run and subsequent copy checks. The thrower-only cases need the vtable-sized prefix, so reducing their memcpy length avoids reading a message pointer from smaller exception objects. Type and what() assertions still execute. The length is restored before CheckCopies, which retains its full object/message and system-error payload checks.

Validation: Exact head and baseline GuestSceV2Exceptions.cpp both pass MinGW GCC C++23 syntax compilation against their respective headers. Conventions, whitespace and script registration passed. This is source and compilation evidence: no linked native test or sanitizer run was performed locally. Hosted metadata/conventions succeeded, but all product and relinker jobs were skipped; their workflow success is not a runtime test pass.

Scope: Approval covers the bounded test-only read-length correction and preservation of adjacent assertions. It does not claim native exception execution or an ASan reproduction.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641423886 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10829#pullrequestreview-5641423886). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-25T04:03:14Z. **Review:** APPROVED --- Reviewed `006b5839f52c83cf17174585dd896692adeb1253` against `25c1aa1e79329e0e2957b4fdd731144dad8be724`. No actionable findings in this focused review. **Source review:** Inspected the complete change, SceV2Inspect/Run and subsequent copy checks. The thrower-only cases need the vtable-sized prefix, so reducing their memcpy length avoids reading a message pointer from smaller exception objects. Type and what() assertions still execute. The length is restored before CheckCopies, which retains its full object/message and system-error payload checks. **Validation:** Exact head and baseline GuestSceV2Exceptions.cpp both pass MinGW GCC C++23 syntax compilation against their respective headers. Conventions, whitespace and script registration passed. This is source and compilation evidence: no linked native test or sanitizer run was performed locally. Hosted metadata/conventions succeeded, but all product and relinker jobs were skipped; their workflow success is not a runtime test pass. **Scope:** Approval covers the bounded test-only read-length correction and preservation of adjacent assertions. It does not claim native exception execution or an ASan reproduction.
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!10829
No description provided.