fix(relinker): reject section header file ranges outside the input file #9168
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9168"
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 slopgobblercobbler on 2026-10-21T14:09:28Z.
What
Validate that ELF section headers with file contents (
sh_typenotSHT_NULLorSHT_NOBITSand non-zerosh_size) lie within the input file buffer inElfReader::ReadSectionHeaders. AddSHT_NOBITSconstant toElfConstants.hppand add comprehensive bounds coverage toElfReaderBoundsTests.cpp(including past-EOF rejection, integer offset overflow, exact-EOF boundary, empty sections, and unbackedSHT_NOBITSsections).Tested
Local C++ unit tests in
ElfReaderBoundsTestson Windows (elf_reader_bounds_tests.exe), building via CMake + Ninja and verified via CTest.tools/check_conventions.pyandtools/pr_overlap.py.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)Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-21T22:07:28Z.
Review: COMMENTED
Confirmed on macOS Apple Silicon, arm64 and x86-64 under Rosetta (your run was Windows only).
66b631498on currentmaina6dcea9279(merged clean).-DCMAKE_OSX_ARCHITECTURES=x86_64 -DPython3_EXECUTABLE=/usr/bin/python3, Python 3.9.6) 229/229.Red/green on
elf_reader_bounds: with theReadSectionHeadersbounds check reverted tomain(newElfReaderBoundsTestskept), the test fails; with the fix it passes. So the added coverage (past-EOF rejection, offset overflow, exact-EOF boundary, empty sections, unbackedSHT_NOBITS) really protects the "section file range outside the input file" regression.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.