Repository navigation
fix(relinker): preserve Linux guest RELRO - #20573
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the focused checks reported by the author cover the preserved RELRO header and Linux page protection behavior.
What I ran
Reviewed head 5fbcbe58d187e3110e3139ec7c7dfea84afcb019. Read description.md, commits.md, manifest.json, diff.patch, core/relinker/CMakeLists.txt, core/relinker/elfpatcher/src/linux/LinuxGuestModuleWriter.cpp, core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp, and core/relinker/relinker/src/parsing/ElfReader.cpp. The complete changed-file texts were included in the review folder; no changed files were excluded. No commands or tests were run in this review. The author-reported build and test results are summarized separately below.
Results
| Check | Result | Note |
|---|---|---|
| Patch and targeted code review | passed | RELRO preservation and validation inspected |
| Author-reported focused tests | passed | Windows and Linux runs reported in PR description |
| Tests run during review | not run | No local build or test execution |
| Branch composition | not run | Author reports shared-CMake comparisons were incomplete |
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently run the builds, focused CTests, convention check, or diff check. Composition with the listed PR branches was not built. No physical-console behavior was verified.
To get this to a good state
Nothing is required.
|
Tested
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
|
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.
|
|
Regression report: since this merged, the Linux relinker rejects a title's bundled module that Error. PPSA05595, Linux, relinking Segments. What
On the console these are 16 KiB pages ( Why plain acceptance isn't enough. On a 4 KiB host, 0x4a000–0x4c000 really is unmapped in the output, so protecting the full RELRO range would fail at load time. A fix probably needs to clip the emitted RELRO to the pages the segment actually maps, here 0x48000–0x4a000, rather than reject the module. The title's other bundled PRX files may have the same layout. The same tree with AI-assisted: yes |
|
Follow-up on the impact. I scanned the modules of 83 locally staged PS5 titles. Each has at least one PRX whose The modules are mostly the usual bundled system ones: The scan is approximate: it does not skip AI-assisted: yes |
|
Fix opened as #25786: it trims a RELRO tail that lies in its segment's own alignment padding to the mapped pages, and keeps this PR's other rejections, AI-assisted: yes |
What
Preserve a valid guest
PT_GNU_RELROheader, including normalizedPT_SCE_RELRO, when writing Linux modules. Previously the writer dropped it even while settingDF_BIND_NOW, leaving relocated data writable.Validate the pages the Linux loader actually protects: both range boundaries round down, partial trailing pages remain outside the protected interval, and already read-only LOAD mappings remain valid. Reject overflow, missing mappings and unsupported multiple nonempty RELRO headers. Keep LOAD offsets and virtual addresses unchanged. The loader applies the protection separately from eager binding (glibc implementation).
Tested
Windows / WinLibs GCC 15.2 / Python 3.12: relinker-only build and seven focused CTests passed:
linux_guest_relro,sce_relro,guest_module_directories,linux_gnu_segments,linux_guest_stack,guest_load_start_module_defer, andlinux_load_bounds.Linux x86_64 in WSL / GCC 15.2 / Python 3.14: native build and
linux_guest_relro,sce_relro,guest_module_directoriespassed. Native subprocess checks confirm relocation/read success, SIGSEGV on writes to protected pages, and writes succeeding outside those pages. Fixtures cover standalone/covered SCE and GNU headers, BSS, empty/subpage ranges, partial/unmapped tails, R/RX/RW LOADs, adjacent mappings, deferred initialization, and invalid/multiple ranges. The original executable failed the preserved-header regression; added valid boundary cases also caught and corrected acceptance errors during review.python tools/check_conventions.py --base origin/mainandgit diff --checkpassed. The required branch overlap scan could not complete 17 shared-CMake comparisons: #6149, #7531, #10861, #11628, #11661, #11689, #11698, #12678, #13486, #13716, #15245, #15642, #15896, #17451, #17473, #17557, #17558. Every reported CMake patch was reviewed manually; none registers this target/fixture or implements guest RELRO. #19706 moves LOAD file offsets while retaining the virtual addresses used for RELRO, so it is independent. Composition with those branches was not built. Based on current main; affected sources are unchanged between the tested and rebased base revisions. No title or performance claim.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)