Skip to content

fix(relinker): reject zero DT_RELR address when relocation table size is non-zero - #278

Open
Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/14505
Open

Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/14505

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#14505, originally opened by slopgobblercobbler.

Source commit: d70e0e72a6f005fac6a590105233f85cc02ea34a. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

Reject a zero DT_RELR address when relocation table size is non-zero, while preserving empty result for zero-size tables. Move test coverage to registered RelrRelocationTests.cpp and remove extraneous notes and unregistered files.

Tested

Verified via unit test execution in RelrRelocationTests.cpp and zero findings with tools/check_conventions.py --base upstream/main.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Invalid nonempty RELR metadata with a zero address is now rejected. Empty RELR tables with a zero address remain accepted.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: RELR validation

Layer / File(s) Summary
Zero-address handling
core/relinker/relinker/src/parsing/RelrRelocations.cpp, core/relinker/relinker/tests/RelrRelocationTests.cpp
The reader throws RelinkerException with DT_RELR address is zero when RELR metadata is nonempty and DT_RELR is zero. Tests cover the rejection and verify that an empty table returns an empty result.

Suggested reviewers: slopgobblercobbler

Change: Bug fix

Merge Risk: Minimal · up to d70e0

The relinker now reports a clear error for malformed RELR metadata with a zero address and a nonzero size. Empty tables still work, and no merge-blocking risk was identified.

Security architecture risk: Minimal · up to d70e0

Relinker rejects a nonempty RELR table at address zero before applying relink patches or returning a converted image. Empty RELR tables remain accepted under the existing metadata checks.

Security review details

Trust Boundaries and Controls

  • observed — The new guard validates input-derived dynamic metadata before translating the RELR table address into a file offset or reading table words. Nonempty tables with nonzero addresses still go through the existing file-backed segment and ambiguity checks.

Rollout and rollback

  • inferred — The parser now stops conversion for this metadata combination regardless of conversion options. An affected operator must supply a corrected or replacement ELF input; retrying the same input under the same build does not clear the check.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 316fd3be-8fd5-4b7e-8658-8100f684c7a0
Commits

Reviewing files that changed from the base of the PR and between 5cf487d and d70e0e7.

Files selected for processing: 2

  • core/relinker/relinker/src/parsing/RelrRelocations.cpp
  • core/relinker/relinker/tests/RelrRelocationTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants