fix(relinker): reject overflowing ELF segment address ranges #19470
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19470"
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 sumoondev on 2026-11-13T11:22:16Z.
What
Add virtual address range overflow validation to
ElfReader::ReadProgramHeaders().PT_LOADsegments whenMappedAddress + MemorySizewould overflowuint64_t.PT_SCE_RELROranges before converting them intoPT_LOADsegments.UINT64_MAXboundary.Tested
elf_reader_bounds_tests— passed.elf_reader_bounds— passed (96 cases).linux_load_alignment— passed.linux_load_bounds— passed.sce_relro— passed.python3 tools/check_conventions.py --base origin/main— passed.Checklist
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](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T18:18:48Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
cf182bc96d:tools/check_conventions.pyfailed;git diff --checkclean.elf_reader_bounds_testsbuilt cleanly.elf_reader_bounds):core/relinker/relinker/src/parsing/ElfReader.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.ph.MemorySize > std::numeric_limits<std::uint64_t>::max() - ph.MappedAddresscorrectly detects virtual address overflow for PT_LOAD segments without triggering unsigned underflow or wrapping.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by sumoondev on 2026-11-14T04:37:11Z.
Review: COMMENTED
Thanks for the review. I've updated both the commit subject and PR title to follow Conventional Commits.
I've also reviewed the overlapping PRs. The relevant changes concern alignment validation, while this PR addresses virtual-address range overflow. They are separate checks, and this PR does not depend on those PRs (
Depends on: none).Please let me know if any further changes are needed.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T20:24:08Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
72b88e2852:tools/check_conventions.pypassed;git diff --checkclean.elf_reader_bounds_testsbuilt cleanly.elf_reader_bounds):core/relinker/relinker/src/parsing/ElfReader.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T20:24:09Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
72b88e2852:tools/check_conventions.pypassed;git diff --checkclean.elf_reader_bounds_testsbuilt cleanly.elf_reader_bounds):core/relinker/relinker/src/parsing/ElfReader.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T04:20:01Z.
Review: APPROVED
Reviewed — looks good
The change at head
72b88e285290240508cce3314ccda0de210cb91frejects overflowing load and uncovered RELRO ranges, and the inspected implementation and regression cases support merging.What I ran
Read the prepared diff and both changed files at the pinned head. No build or tests were run in this review; the test results in the PR description are author-reported.
Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
No commands, build, or tests were run. The author-reported test outcomes and convention check were not independently verified. All changed files listed in the manifest were read; no files were excluded by the manifest.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by catminou4 on 2026-11-25T06:56:05Z.
Review: CHANGES_REQUESTED
Reviewed at
72b88e2852, both on its own head and applied onmain7a1c9bbccf, relinker-only Release build (GCC, Ubuntu 22.04).ctest -R '^elf_reader_bounds$': passes. Control: withElfReader.cppfrommain,load address range overflowanduncovered SCE RELRO address range overflow before PT_LOAD conversionfail (Invalid program header was accepted); restoring the PR source passes again.ctestnow failsguest_load_ranges, on the PR head and onmain+ PR:GuestLoadRangesTests.cpp:76-80(a segment atUINT64_MAXwithp_memsz1) was already rejected onmain, just later. The newElfReadercheck catches it first with a different message. Update those expectations, or use the existing diagnostic.translation virtual boundary/translation ... near virtual maximumaway fromUINT64_MAX - 31is expected: a segment that ends at 2^64 is now rejected.Not mergeable until
guest_load_rangespasses.Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:55:28Z.
Review: COMMENTED
Built this head with
ANYPS5_RELINKER_ONLY=ONand ran the repository’self_reader_boundssuite on Linux. It passed, including the added segment-address overflow checks.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T02:19:39Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
f071650e83bfc24a5cdf0468ed3e1c33dcda4319. Read the prepared description, commits, manifest and diff, plus the changed code and relevant test sections usingrepo_read.py. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently run the reported test suites or convention check, or verify CI results. No files were excluded by the manifest.
To get this to a good state
Nothing is required.
Sources
The new PT_LOAD and uncovered PT_SCE_RELRO range checks and their boundary cases are in ElfReader.cpp and ElfReaderBoundsTests.cpp.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.