test(relinker): audit eh_frame_hdr bounds and author fuzzer harnesses #15642

Open
slopgobblercobbler wants to merge 1 commit from upstream-pr/15642 into main
slopgobblercobbler commented 2026-11-03 22:49:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-11-03T22:49:20Z.


What

  • Focus test coverage on eh_frame_hdr binary search table bounds in UnwindDescriptorNegativeBoundsTests.cpp, validating rejection of truncated segments, unsupported versions, omitted encodings, invalid frame counts, out-of-bounds tables, and verifying idempotent handling of duplicate search table entries.
  • Added libFuzzer harnesses (ElfParserFuzzer.cpp and UnwindDescriptorFuzzer.cpp) under ANYPS5_BUILD_FUZZERS (off by default) targeting ELF parsing and DWARF exception function reconstruction, catching only RelinkerException.
  • Dropped overlapping ELF parser boundary tests and test runner executables per maintainer review.
  • Documented .eh_frame_hdr binary search table bounds debt in docs/dev/debt/relinker.md.

Tested

  • Built and executed standalone test verifying all assertions pass.
  • Verified conventions check passes with 0 findings (python tools/check_conventions.py --base upstream/main).

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5145719959 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15642). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-11-03T22:49:20Z. --- ### What - Focus test coverage on `eh_frame_hdr` binary search table bounds in `UnwindDescriptorNegativeBoundsTests.cpp`, validating rejection of truncated segments, unsupported versions, omitted encodings, invalid frame counts, out-of-bounds tables, and verifying idempotent handling of duplicate search table entries. - Added libFuzzer harnesses (`ElfParserFuzzer.cpp` and `UnwindDescriptorFuzzer.cpp`) under `ANYPS5_BUILD_FUZZERS` (off by default) targeting ELF parsing and DWARF exception function reconstruction, catching only `RelinkerException`. - Dropped overlapping ELF parser boundary tests and test runner executables per maintainer review. - Documented `.eh_frame_hdr` binary search table bounds debt in `docs/dev/debt/relinker.md`. ### Tested - Built and executed standalone test verifying all assertions pass. - Verified conventions check passes with 0 findings (`python tools/check_conventions.py --base upstream/main`). ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: n/a - [x] AI-assisted: yes
adriadam10 commented 2026-11-07 18:52:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-07T18:52:11Z.

Review: CHANGES_REQUESTED


The negative-bounds suites look reasonable. Points to fix before merge:

  • core/relinker/fuzz/ElfParserFuzzer.cpp:46 and UnwindDescriptorFuzzer.cpp:46: catch (const std::exception&) swallows everything, so a std::length_error/out_of_range from an unchecked size counts as a clean rejection. Catch only RelinkerException (and std::bad_alloc if you want it), so the harness fails on any other exception.
  • ElfParserFuzzTests.cpp:36-40: seed[80] = 0x1000, seed[88] = 0x1000 write a value above 255 into a single byte (it becomes 0). Use a 16/64-bit write like ElfParserNegativeBoundsTests.cpp does, otherwise the seed being mutated is not the ELF you describe.
  • ElfParserFuzzTests.cpp / UnwindDescriptorFuzzTests.cpp: the runners assert nothing beyond "does not crash". Please assert that the unmutated seed is accepted (headers parsed / one region returned), so a seed that is rejected at byte 0 can't pass as 1000+ cases.
  • ElfParserNegativeBoundsTests.cpp:24: Require is never used; remove the dead helper.

Feel free to push the fixes and ping for a re-review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5814413944 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15642#pullrequestreview-5814413944). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-07T18:52:11Z. **Review:** CHANGES_REQUESTED --- The negative-bounds suites look reasonable. Points to fix before merge: - `core/relinker/fuzz/ElfParserFuzzer.cpp:46` and `UnwindDescriptorFuzzer.cpp:46`: `catch (const std::exception&)` swallows everything, so a `std::length_error`/`out_of_range` from an unchecked size counts as a clean rejection. Catch only `RelinkerException` (and `std::bad_alloc` if you want it), so the harness fails on any other exception. - `ElfParserFuzzTests.cpp:36-40`: `seed[80] = 0x1000`, `seed[88] = 0x1000` write a value above 255 into a single byte (it becomes 0). Use a 16/64-bit write like `ElfParserNegativeBoundsTests.cpp` does, otherwise the seed being mutated is not the ELF you describe. - `ElfParserFuzzTests.cpp` / `UnwindDescriptorFuzzTests.cpp`: the runners assert nothing beyond "does not crash". Please assert that the unmutated seed is accepted (headers parsed / one region returned), so a seed that is rejected at byte 0 can't pass as 1000+ cases. - `ElfParserNegativeBoundsTests.cpp:24`: `Require` is never used; remove the dead helper. Feel free to push the fixes and ping for a re-review.
MarcZX10 commented 2026-11-21 05:14:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T05:14:01Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this review; the change adds test and fuzz harnesses without changing parser implementation behavior.

What I ran

Reviewed head 7e3ff9c3a1fd64c8087350eafbff9c0c83549fb1 against the prepared diff. No build or test commands were run; author-reported checks are not independently verified.

Results

Check Result Note
Diff and changed files passed All eight changed files read
Build and tests not run Windows/MSVC results are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

No compilation or CTest run was performed. The stated Windows x64/MSVC C++20 results and convention check were not independently confirmed. The repository reader exposes no files.json; the changed-file inventory was checked through the review folder listing and manifest. The full changed text was read for all eight files.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003023029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15642#pullrequestreview-6003023029). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T05:14:01Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this review; the change adds test and fuzz harnesses without changing parser implementation behavior. ## What I ran Reviewed head `7e3ff9c3a1fd64c8087350eafbff9c0c83549fb1` against the prepared diff. No build or test commands were run; author-reported checks are not independently verified. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All eight changed files read | | Build and tests | not run | Windows/MSVC results are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No compilation or CTest run was performed. The stated Windows x64/MSVC C++20 results and convention check were not independently confirmed. The repository reader exposes no `files.json`; the changed-file inventory was checked through the review folder listing and manifest. The full changed text was read for all eight files. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-22 12:27:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T12:27:53Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review supports adding the bounds tests and optional fuzz targets, but builds and tests were not run here.

What I ran

Reviewed head 2004699d1663e0b5c218ae14b310231b02f76d17 using the prepared diff and the pinned repository reader. No commands, builds, or tests were run.

Results

Check Result Note
Diff and changed files passed Five changed files read
Targeted source context passed Fuzzer configuration and unwind reader read
Build and tests not run No execution environment available

Findings

Blocking

None.

Non-blocking

None.

Not verified

Build and test results reported in the PR description were not independently verified. The full review bundle listed five files under reviewed; all five were read: core/relinker/CMakeLists.txt, core/relinker/fuzz/ElfParserFuzzer.cpp, core/relinker/fuzz/UnwindDescriptorFuzzer.cpp, core/relinker/relinker/tests/UnwindDescriptorNegativeBoundsTests.cpp, and docs/dev/debt/relinker.md. No changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012217720 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15642#pullrequestreview-6012217720). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T12:27:53Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review supports adding the bounds tests and optional fuzz targets, but builds and tests were not run here. ## What I ran Reviewed head `2004699d1663e0b5c218ae14b310231b02f76d17` using the prepared diff and the pinned repository reader. No commands, builds, or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | Five changed files read | | Targeted source context | passed | Fuzzer configuration and unwind reader read | | Build and tests | not run | No execution environment available | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Build and test results reported in the PR description were not independently verified. The full review bundle listed five files under `reviewed`; all five were read: `core/relinker/CMakeLists.txt`, `core/relinker/fuzz/ElfParserFuzzer.cpp`, `core/relinker/fuzz/UnwindDescriptorFuzzer.cpp`, `core/relinker/relinker/tests/UnwindDescriptorNegativeBoundsTests.cpp`, and `docs/dev/debt/relinker.md`. No changed files were excluded. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 13:48:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:48:17Z.

Review: COMMENTED


The exact branch passed the unwind descriptor bounds CTest in a Linux relinker-only build. This run covered the registered unit test.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6171034076 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15642#pullrequestreview-6171034076). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:48:17Z. **Review:** COMMENTED --- The exact branch passed the unwind descriptor bounds CTest in a Linux relinker-only build. This run covered the registered unit test. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/15642:upstream-pr/15642'
git switch 'upstream-pr/15642'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/15642'
git switch 'upstream-pr/15642'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/15642'
git switch 'upstream-pr/15642'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/15642'
git switch 'main'
git merge --squash 'upstream-pr/15642'
git switch 'main'
git merge --ff-only 'upstream-pr/15642'
git switch 'main'
git merge 'upstream-pr/15642'
git push origin 'main'
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!15642
No description provided.