You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reject malformed ELF SHT_DYNAMIC section headers whose sh_entsize is not the ELF64 dynamic-entry size (16 bytes).
ElfReader::ReadSectionHeaders() already validates sh_entsize for symbol and relocation sections but previously accepted any value for SHT_DYNAMIC. The parser now uses the existing kDynEntrySize constant, the bounds fixture keeps its synthetic dynamic section otherwise valid, and the relinker debt entry records the additional validation.
Tested
Windows 11, MSYS2 UCRT64 GCC 16.2.0, CMake 4.4, Ninja, Release relinker-only build on machine main.
Negative control on unpatched current main: keeping only the new regression makes elf_reader_bounds fail at SHT_DYNAMIC section entry size mismatch with Invalid section metadata was accepted.
Fixed head: elf_reader_bounds passes.
Full relinker-only suite: 1088/1088 tests passed.
git diff --check passed.
python tools/check_conventions.py --base origin/main --head HEAD passed.
Test registration passed: 67 test executables with none newly built-and-unrun; 336 test scripts are registered.
Rebased onto current main 87b7ef3891afc17113b86b14815f96895ae477cf; focused test and gates pass again on head 3a0287fc8f98cf6ebf1d1b5eef16255c4b74bd5c.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@malekaifa the new test does not compile on Linux at 3a0287fc8f. In the first loop the braced list mixes 0ULL style literals (unsigned long long) with std::numeric_limits<std::uint64_t>::max() (unsigned long where uint64_t is unsigned long), so initializer_list deduction for the range-for fails. Please write the loop over std::initializer_list<std::uint64_t>{...} or cast each element to std::uint64_t. The check itself in the relinker looks right to me.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed — looks good
Nothing blocks this change; the parser check and regression test support the stated validation, and the reviewed files support merging.
What I ran
Reviewed head 3a0287fc8f98cf6ebf1d1b5eef16255c4b74bd5c using the prepared diff and pinned reader. No build or test commands were run.
Results
Check
Result
Note
Diff and changed files
passed
Three changed files read
Build and tests
not run
Author reports passing gates
Console behavior
not run
Hardware diagnostics remain unverified
Findings
Blocking
None.
Non-blocking
None.
Not verified
No commands or tests were run independently. PS5 hardware behavior was not verified. The complete file contents were read for all files listed as reviewed; no files were excluded in manifest.json.
Fixed the Linux compile issue from @oneandonlydean on current head 70f127160c8b17e8db622fa0ce59e5667464dc9c: the mixed braced list is now an explicit std::initializer_list<std::uint64_t>, with no production-code change.
The reason will be displayed to describe this comment to others. Learn more.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 70f127160c:
Conventions: tools/check_conventions.py passed.
Build: elf_reader_bounds_tests built cleanly.
CTest (elf_reader_bounds):
1/1 Test #6364: elf_reader_bounds ................ Passed 0.00 sec
100% tests passed, 0 tests failed out of 1
Negative control: with core/relinker/relinker/src/parsing/ElfReader.cpp reverted to main and the new tests kept, the suite fails:
1/1 Test #6364: elf_reader_bounds ................***Failed 0.00 sec
0% tests passed, 1 tests failed out of 1
Restoring the change makes it pass again.
Code reading:
Validated core/relinker/relinker/src/parsing/ElfReader.cpp:267-269 ElfReader::ReadSectionHeaders() correctly validates sh.Type == SHT_DYNAMIC with sh.EntrySize != kDynEntrySize (16 bytes) and throws RelinkerException with the exact offset offset + kShdrEntSizeOffset, mirroring SHT_SYMTAB/DYNSYM and SHT_RELA/REL checks.
Verified docs/dev/debt/relinker.md correctly updates the debt entry to document that dynamic section entry size is now validated alongside symbol and relocation sections.
Verified core/relinker/relinker/tests/ElfReaderBoundsTests.cpp lines 1066 and 1096-1103: regression test comprehensively covers various invalid entry sizes (0, 1, 8, 15, 17, 24, 32, 64, UINT64_MAX) using explicit std::initializer_liststd::uint64_t and validates valid size 16.
Checked AGENTS.md rules: no prohibited comments added, no stubs or single-game workarounds introduced, conventional commit and PR structure respected, no extra files added.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed — looks good
The change validates SHT_DYNAMIC entry sizes and adds a focused regression test; the reviewed files support merging.
What I ran
Reviewed head 70f127160c8b17e8db622fa0ce59e5667464dc9c. I did not run commands or tests; repo_read.py was unavailable as a command in this environment. The author reports the focused test, full suite, and stated gates passed.
Results
Check
Result
Note
Code and diff review
passed
All changed files read
Tests and other gates
not run
Results supplied by author only
Findings
Blocking
None.
Non-blocking
None.
Sources
Reviewed core/relinker/relinker/src/parsing/ElfReader.cpp, core/relinker/relinker/tests/ElfReaderBoundsTests.cpp, and docs/dev/debt/relinker.md; all are included in the review bundle and were read. No files were excluded.
Not verified
Tests, build, convention checks, and test registration were not run by me. PS5 hardware and console-loader diagnostics were not tested, as noted in the PR description.
Maintainer handoff: current head 70f127160c8b17e8db622fa0ce59e5667464dc9c is mergeable/clean. The repaired exact head now has green relinker jobs on Windows, Ubuntu, macOS and ASan, plus green eligibility, PR, conventions and labels checks. PrivacyOnion and MarcZX10 both approved this exact head, and PrivacyOnion independently rebuilt elf_reader_bounds_tests, passed elf_reader_bounds, and confirmed the negative control fails without the parser fix. No remaining blocker is known from this review/CI pass.
Rebased onto current main7a3206e9cd8c as head d519ded26f6905837eb231864f5f871196df0dfe. Machine main: rebuilt elf_reader_bounds_tests; ctest -R ^elf_reader_bounds$ passes 1/1 on this exact head, and git diff --check passes. Fresh hosted checks are running.
Current stable head is b45fa671169cf6cc4bd0c2bf3168d42577e691d1, based on db397a73fe4754858e19483fd6cb29159ed57d74. The Linux initializer fix remains in place; elf_reader_bounds_tests rebuilt and elf_reader_bounds passed 1/1 on machine main, conventions/test registration/diff checks passed, and GitHub reports the PR mergeable/clean. I will not rebase it again merely to chase a moving main; this head stays stable unless a real conflict, integration dependency, or reviewer request appears. AI-assisted: yes
@MarcZX10@PrivacyOnion The current stable PR head is b45fa671169cf6cc4bd0c2bf3168d42577e691d1, newer than the last reviewed head. Could you please re-review this exact head when convenient?
Final exact-head handoff: current head b02f7781262a69c6fcaf21dcf41129ca1f18382d has all 14 hosted checks complete/pass-or-intentionally-skipped, including Windows/Ubuntu/macOS relinker and ASan, conventions, eligibility, PR and labels. GitHub review records attach both PrivacyOnion and MarcZX10 approvals to this exact head, and the PR is mergeable. No remaining blocker is known. AI-assisted: yes
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.
Manual overlap follow-up for the latest bot warning: I inspected the shared-file diffs of #11661, #11689 and #11698. Their ElfReader.cpp changes are in other validation paths (including PT_LOAD alignment / RELRO handling); none of the three contains an SHT_DYNAMIC, sh_entsize, kDynEntrySize, or dynamic-section-entry-size change. Their ElfReaderBoundsTests.cpp / debt edits likewise do not implement #25435's validation. So these are shared-file/integration overlaps, not a competing implementation of this PR. No source change is needed from this overlap review. AI-assisted: yes (OpenAI ChatGPT).
Rebased onto current main as head 3cf4af1. Machine main: rebuilt elf_reader_bounds_tests; elf_reader_bounds passes 1/1, conventions pass, all 338 test scripts are registered, and git diff --check passes. Fresh hosted checks are starting.
Applied PR head 3cf4af18f039ccbfc0e1285a114099ab2be72278 to current main fd653794a1538fdde37ae77971e3f345ced33e85; merge was clean.
Configured a relinker-only Release build with MSYS2 UCRT64 GCC 16.2 and built elf_reader_bounds_tests.
CTest elf_reader_bounds: 1/1 passed.
Negative control: restored current main's unpatched ElfReader.cpp while keeping the PR regression test; the test failed specifically at SHT_DYNAMIC section entry size mismatch because invalid metadata was accepted. Restoring the PR implementation made it pass again.
This independently verifies the dynamic-section entry-size regression on the current-main merge. Hosted Ubuntu/Windows/macOS relinker, ASan, conventions, eligibility, and labels checks are green. AI-assisted: yes (OpenAI ChatGPT).
ReadSectionHeaders rejects SHT_DYNAMIC entry sizes other than kDynEntrySize. Tests cover zero, other invalid sizes, the maximum uint64_t, and failure offset 248. The section-link test sets entry size 16 for section types 6 and 9. The debt entry documents dynamic-section entry-size validation and unmeasured console diagnostics.
Suggested reviewers:slopgobblercobbler
Change: Bug fix
Merge Risk: Minimal · previous review 0681e
The relinker's ELF reader now rejects dynamic sections whose entry size is not 16 bytes, matching what the writer already produces. Only malformed inputs are affected, and tests cover the rejection. No merge-blocking risk remains.
Security architecture risk: Minimal · up to 0681e
The reader now rejects malformed dynamic section headers that it previously accepted, without changing the files the relinker writes. The change adds a rejection check rather than a new way for input to reach downstream processing.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The direct exposure change is limited to callers parsing section headers from ELF inputs with nonconforming SHT_DYNAMIC metadata. The new branch can stop those inputs earlier; it adds no route to downstream processing.
Trust Boundaries and Controls
observed — The reader compares the file-supplied entry size with a fixed format constant and uses the existing parser exception mechanism to reject a mismatch.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 65f65186-f589-4829-a7d1-71dacc32f3c3
Commits
Reviewing files that changed from the base of the PR and between 10fef81 and 0681eb7.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Reject malformed ELF
SHT_DYNAMICsection headers whosesh_entsizeis not the ELF64 dynamic-entry size (16 bytes).ElfReader::ReadSectionHeaders()already validatessh_entsizefor symbol and relocation sections but previously accepted any value forSHT_DYNAMIC. The parser now uses the existingkDynEntrySizeconstant, the bounds fixture keeps its synthetic dynamic section otherwise valid, and the relinker debt entry records the additional validation.Tested
main.elf_reader_boundsfail atSHT_DYNAMIC section entry size mismatchwithInvalid section metadata was accepted.elf_reader_boundspasses.git diff --checkpassed.python tools/check_conventions.py --base origin/main --head HEADpassed.87b7ef3891afc17113b86b14815f96895ae477cf; focused test and gates pass again on head3a0287fc8f98cf6ebf1d1b5eef16255c4b74bd5c.tools/pr_overlap.pyscanned 2,349 open PRs. It found no confirmed semantic overlap but failed closed on old conflicting-base branches. I manually reviewed every reported branch: fix(relinker): analyze referenced code beyond SCE scan boundaries #10861, fix(relinker): keep embedded data tables out of --to-intel and --to-rosetta conversion #11525, feat(relinker): support short scalar guest GS instructions #11661, feat(relinker): support SSE guest GS memory accesses #11689, feat(relinker): support VEX guest GS memory accesses #11698, feat(relinker): add opt-in PEXT and PDEP lowering for Rosetta #12678, fix(relinker): tell code from data in images without PT_SCE_DYNLIBDATA #13716, fix(relinker): classify call sites behind REP and operand-size prefixes #14241, fix(relinker): resolve a needed module on the executable that exports its imports #15245, feat(relinker): emit per-NID call hook table #17557 and feat(tools): nid_names client for the debugger #17558. The three branches sharingElfReader.cpp/ElfReaderBoundsTests.cpp(feat(relinker): support short scalar guest GS instructions #11661/feat(relinker): support SSE guest GS memory accesses #11689/feat(relinker): support VEX guest GS memory accesses #11698) only modifyReadProgramHeaders()alignment validation and tests around that path; the others touch unrelated relinker debt entries. None implements or edits theSHT_DYNAMICentry-size check.SHT_DYNAMIC.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 file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit