fix(relinker): protect registry output from inputs #2100

Closed
AaravMehta-07 wants to merge 1 commit from upstream-pr/2100 into main
AaravMehta-07 commented 2026-10-09 08:36:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AaravMehta-07 on 2026-10-09T08:36:40Z.


What

Reject --registry output paths that refer to either the main executable input or a bundled guest-module input. The relinker now checks the registry path against the exact module input inventory already discovered by GuestModuleBuilder, including filesystem aliases, before writing registry or converted outputs. A missing registry destination remains valid. This prevents a successful conversion from replacing an input ELF with JSON.

Tested

  • Before rebase (f37e7fa3), Windows 11 / WinLibs GCC 15.2 relinker-only build and full relinker CTest suite passed (36/36). tls_function_coverage took 68.36 seconds locally.
  • Before rebase (f37e7fa3), Ubuntu WSL / GCC 15.2 relinker build and full relinker CTest suite passed (39/39). import_audit took 160.91 seconds on the mounted Windows worktree.
  • After rebase (d60ed99a on d9484c71), Windows relinker-only build passed (151/151 build steps) and focused call_registry CTest passed (1/1, 27.74 seconds).
  • After rebase (d60ed99a on d9484c71), Ubuntu WSL relinker build passed (6/6 build steps) and focused call_registry CTest passed (1/1, 4.68 seconds).
  • Hosted checks for rebased head d60ed99a completed: conventions and eligibility passed; automatic relinker and full-project Linux/Windows jobs were skipped by #2113's contributor eligibility gate. Full-project builds require manual dispatch.
  • Regression tests cover a registry destination matching a bundled module filename and a hardlink alias, for Linux and Windows conversion modes; they verify rejection and preservation of source bytes, and that no executable or app0 output was created.
  • python tools/check_conventions.py --base upstream/main passed.
  • Rebased on main at d9484c719b2a5ac6201e27f8657e0fb0f01e648c, which includes #2099's SPIRV-Headers include fix and #2113's CI workflow change. At the previous head, hosted relinker jobs passed on Windows, Linux, and macOS and conventions passed. The previous full-project Windows/Linux builds failed in unchanged agc_shader_fusion_tests because its include list omitted 3rdparty/SPIRV-Headers/include; base and PR blob hashes for the relevant AGC files matched, and a local WinLibs GCC 15.2 compile reproduced the failure and passed with that include root added. The upstream include fix has since merged; no AGC code is part of this PR. Under #2113, full-project builds are manual rather than automatic for contributor PRs.

Checklist

  • Based on current main; no other open PR implements this input-overwrite protection. PR #1462 adds per-module registry output. PR #1815 changes nested guest-module discovery earlier in GuestModuleBuilder::Build; this preflight follows the completed input inventory and checks its paths, including any newly discovered modules. The behavior is complementary and has no dependency on #1815.
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except permitted technical-debt comments
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4798086321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2100). Originally posted by [AaravMehta-07](https://github.com/AaravMehta-07) on 2026-10-09T08:36:40Z. --- ### What Reject `--registry` output paths that refer to either the main executable input or a bundled guest-module input. The relinker now checks the registry path against the exact module input inventory already discovered by `GuestModuleBuilder`, including filesystem aliases, before writing registry or converted outputs. A missing registry destination remains valid. This prevents a successful conversion from replacing an input ELF with JSON. ### Tested - Before rebase (`f37e7fa3`), Windows 11 / WinLibs GCC 15.2 relinker-only build and full relinker CTest suite passed (36/36). `tls_function_coverage` took 68.36 seconds locally. - Before rebase (`f37e7fa3`), Ubuntu WSL / GCC 15.2 relinker build and full relinker CTest suite passed (39/39). `import_audit` took 160.91 seconds on the mounted Windows worktree. - After rebase (`d60ed99a` on `d9484c71`), Windows relinker-only build passed (151/151 build steps) and focused `call_registry` CTest passed (1/1, 27.74 seconds). - After rebase (`d60ed99a` on `d9484c71`), Ubuntu WSL relinker build passed (6/6 build steps) and focused `call_registry` CTest passed (1/1, 4.68 seconds). - Hosted checks for rebased head `d60ed99a` completed: conventions and eligibility passed; automatic relinker and full-project Linux/Windows jobs were skipped by #2113's contributor eligibility gate. Full-project builds require manual dispatch. - Regression tests cover a registry destination matching a bundled module filename and a hardlink alias, for Linux and Windows conversion modes; they verify rejection and preservation of source bytes, and that no executable or `app0` output was created. - `python tools/check_conventions.py --base upstream/main` passed. - Rebased on `main` at `d9484c719b2a5ac6201e27f8657e0fb0f01e648c`, which includes [#2099](https://github.com/boykopovar/AnyPS5/pull/2099)'s SPIRV-Headers include fix and [#2113](https://github.com/boykopovar/AnyPS5/pull/2113)'s CI workflow change. At the previous head, hosted relinker jobs passed on Windows, Linux, and macOS and conventions passed. The previous full-project Windows/Linux builds failed in unchanged `agc_shader_fusion_tests` because its include list omitted `3rdparty/SPIRV-Headers/include`; base and PR blob hashes for the relevant AGC files matched, and a local WinLibs GCC 15.2 compile reproduced the failure and passed with that include root added. The upstream include fix has since merged; no AGC code is part of this PR. Under #2113, full-project builds are manual rather than automatic for contributor PRs. ### Checklist - [x] Based on current `main`; no other open PR implements this input-overwrite protection. PR #1462 adds per-module registry output. [PR #1815](https://github.com/boykopovar/AnyPS5/pull/1815) changes nested guest-module discovery earlier in `GuestModuleBuilder::Build`; this preflight follows the completed input inventory and checks its paths, including any newly discovered modules. The behavior is complementary and has no dependency on #1815. - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except permitted technical-debt comments - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-09 09:05:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T09:05:26Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#2119 core/relinker/main.cpp L94
core/relinker/relinker/include/relinker/guest/GuestImage.hpp L57
core/relinker/relinker/src/guest/GuestModuleBuilder.cpp L34
#2212 core/relinker/main.cpp L94
core/relinker/relinker/include/relinker/guest/GuestImage.hpp L57
core/relinker/relinker/src/guest/GuestModuleBuilder.cpp L34, L89
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077862599 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2100#issuecomment-6077862599). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T09:05:26Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2119 | `core/relinker/main.cpp` [L94](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/core/relinker/main.cpp#L94)<br>`core/relinker/relinker/include/relinker/guest/GuestImage.hpp` [L57](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/core/relinker/relinker/include/relinker/guest/GuestImage.hpp#L57)<br>`core/relinker/relinker/src/guest/GuestModuleBuilder.cpp` [L34](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp#L34) | | | | #2212 | `core/relinker/main.cpp` [L94](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/core/relinker/main.cpp#L94)<br>`core/relinker/relinker/include/relinker/guest/GuestImage.hpp` [L57](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/core/relinker/relinker/include/relinker/guest/GuestImage.hpp#L57)<br>`core/relinker/relinker/src/guest/GuestModuleBuilder.cpp` [L34](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp#L34), [L89](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp#L89) | | |
oneandonlydean commented 2026-10-09 20:08:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:08:46Z.


Closing: this guards against pointing --registry at one of the conversion's own inputs, which nobody has reported running into, and it touches the same lines as several open relinker PRs. Please reopen if it comes up in practice.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088423901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2100#issuecomment-6088423901). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:08:46Z. --- Closing: this guards against pointing `--registry` at one of the conversion's own inputs, which nobody has reported running into, and it touches the same lines as several open relinker PRs. Please reopen if it comes up in practice.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2100
No description provided.