Skip to content

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

Closed
AaravMehta-07 wants to merge 1 commit into
boykopovar:mainfrom
AaravMehta-07:codex/relinker-correctness
Closed

AaravMehta-07 wants to merge 1 commit into
boykopovar:mainfrom
AaravMehta-07:codex/relinker-correctness

Conversation

@AaravMehta-07

@AaravMehta-07 AaravMehta-07 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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 ci(build): require manual full builds and auto-test relinker for contr #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 ci(build): require manual full builds and auto-test relinker for contr #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 feat(relinker): write a registry for each converted bundled module #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 fix(relinker): discover required modules in nested standard directories #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

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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

@oneandonlydean

Copy link
Copy Markdown
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants