fix(relinker): validate ELF program header table bounds #14001
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14001"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by bro4cvf-hash on 2026-10-31T15:07:19Z.
What
Validate ELF program header table bounds before reading headers in
ElfReader. ThrowRelinkerException("Program header table out of bounds") if the program header table offset and total size exceed the file buffer, and add unit tests covering program header table truncation and offset overflow.Tested
Windows 11 (x86_64),
ctest --test-dir build-relinker -R elf_reader_bounds -V:All unit tests in
elf_reader_bounds_testspassed (100% tests passed, 0 failures), including the new test cases:program header table truncationprogram header table offset overflowChecklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T15:09:27Z.
Review: APPROVED
Reviewed — looks good
At head
fc3ad26b7c71af11d80d6d8eddc76f9d4239f527against base73f4f7e06e4f210a8c6570e335fd654dc0a86134, the new program-header range check uses the existing overflow-safe_rangeFitshelper, and the tests cover a truncated table and an out-of-file offset (implementation, tests).git diff --check, conventions/template validation, and the current-base merge preview passed. The Windows CTest result in the PR description is author-reported; I did not build or run the test locally, and no product build job is present in the current hosted check set.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T15:29:59Z.
Review: APPROVED
Reviewed — looks good
The change validates the complete program-header table range before reading entries and adds focused cases for truncation and an extreme offset; I found no blocking issue.
What I ran
Reviewed PR head
fc3ad26b7c71af11d80d6d8eddc76f9d4239f527with its reported base73f4f7e06e4f210a8c6570e335fd654dc0a86134. The clean merge preview used currentmain474030e58424fefdb65e5df9f3820810fbb4553c. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5; no compiler or local test binary was used.I also inspected the range helper, validation order, added test cases, and existing CTest registration.
Results
elf_reader_boundsCTest target includes this test executablemainctest --test-dir build-relinker -R elf_reader_bounds -Vreported all tests inelf_reader_bounds_testspassed; I did not independently run itUnedited check output
Diff check exited 0 with no output.
Conventions:
CTest registration:
Merge preview:
Hosted check runs:
Test-quality helper:
Findings
Blocking: None.
Sources
Not verified
I did not build or run CTest locally. The targeted Windows result is author-reported; hosted build jobs were not present in this check snapshot.
Pull request closed