fix(relinker): reject truncated EH frame headers #2256
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2256"
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 NumberGuan on 2026-10-09T13:24:31Z.
What
EhFrameReader::Readchecks the segment boundary inside the FDE table loop. When the decoded count is zero, that loop never runs: a truncatedPT_GNU_EH_FRAMEheader can consume bytes beyond its declared size and still be accepted. A synthetic header declaring one byte currently relinks successfully.Reject a segment shorter than the four encoding bytes, and reject a decoded header whose cursor exceeds the declared segment size before using its count. The LSB definition of PT_GNU_EH_FRAME specifies the location and size of
.eh_frame_hdr.The shared reader is used by strict NID filtering (
unused-filter=2) and Windows TLS code analysis. Ordinary Linux conversion with filtering disabled does not use this reader and is outside this change.Extend the registered
linux_eh_frame_headerintegration test with fixed-width and ULEB128 headers. Every shorter nonempty segment must exit 2 with the new diagnostic, leave the input unchanged and write no executable. Complete headers must still convert. The matrix covers 44 rejection cases and four valid controls across Linux strict filtering and Windows conversion.This is independent of #2245's signed LEB128 overflow check and #1944's LSDA handling.
git merge-treecombines this branch with each of them without conflicts. No dependency.Tested
Windows x64, WinLibs MinGW-w64 GCC 15.2.0 UCRT POSIX SEH r7, Ninja Release, Python 3.12.14. Based on upstream
d70b8998; contributionec5a2019.All 40 registered test groups passed in 70.14 seconds. Registration, conventions and whitespace checks passed. The focused regression took 1.57 seconds. The existing
tls_function_coveragetest took 64.66 seconds in the full run; no repository timeout was changed.With only the regression added to upstream
d70b8998, the registered test fails becausebounds-linux-strict-fixed-1returns 0 and writes an executable. With the three-line fix it passes, including all 44 malformed inputs and the four valid controls.GitHub Actions passed Conventions and the relinker build/test matrix on Windows, Linux and macOS for
ec5a2019: Build run, Conventions run. The full Linux and Windows build jobs were skipped under the repository's pull-request policy. System-library builds and game/PS5 tests were not run locally.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T13:38:40Z.
Review: APPROVED
Reviewed the complete diff. The size checks reject short program-header segments and any decoded fixed-width or LEB128 header whose cursor crosses the declared segment; the tests verify truncated inputs write no output while complete controls still convert. The relinker-only build and
linux_eh_frame_headerpassed locally (1/1), Conventions passed, and the official Linux, Windows, and macOS relinker jobs are green. This remains separate from #2245, which rejects LEB128 value overflow.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T01:49:34Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/relinker/relinker/tests/test_linux_eh_frame_header.pyL51-54