fix(relinker): validate ELF headers early #1087

Closed
MuhammadUmair1019 wants to merge 1 commit from upstream-pr/1087 into main
MuhammadUmair1019 commented 2026-10-07 10:15:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MuhammadUmair1019 on 2026-10-07T10:15:44Z.


What

Tested

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 in TechnicalDebt
  • 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:
  • AI-assisted:
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4771180675 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1087). Originally posted by [MuhammadUmair1019](https://github.com/MuhammadUmair1019) on 2026-10-07T10:15:44Z. --- ### What ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> - [x] AI-assisted: <!-- yes / no -->
oneandonlydean commented 2026-10-08 03:25:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:25:38Z.


The description is empty; please fill in What, Tested and AI-assisted, and say which input needed these checks. A wrong class or machine already fails on main's bounds checks, so as it stands this only changes the error message.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6051538188 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1087#issuecomment-6051538188). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T03:25:38Z. --- The description is empty; please fill in What, Tested and AI-assisted, and say which input needed these checks. A wrong class or machine already fails on main's bounds checks, so as it stands this only changes the error message.
adriadam10 commented 2026-10-09 22:22:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:22:58Z.

Review: CHANGES_REQUESTED


Ran build + ctest on this merged onto current main: elf_header passes, and it fails with the ElfReader.cpp change reverted, so the test pins the change. Remaining points:

  • The description is still empty (What, Tested, AI-assisted), as @oneandonlydean asked on Oct 8. Please fill it in.
  • Say which input needed each new check. A wrong class or machine already fails on main's bounds checks, so without a concrete input that was accepted (or written out) wrongly, these only change the error message. Checks that reject an input main accepted (e.g. e_version, e_ehsize, ident version) are the ones worth keeping; show it with a case that passes on main.
  • Overlap with #2262, which edits the same ReadHeader lines and the same test_elf_header.py (class / data encoding / ident version). Whichever lands first conflicts the other. Please coordinate: list it under Depends on, and either drop the checks #2262 already covers or rebase on it and keep only machine, version and header size.
  • Please check the new message wording against #2262's after the rebase so the two don't diverge on the same check.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5475891465 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1087#pullrequestreview-5475891465). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T22:22:58Z. **Review:** CHANGES_REQUESTED --- Ran build + ctest on this merged onto current main: `elf_header` passes, and it fails with the `ElfReader.cpp` change reverted, so the test pins the change. Remaining points: - The description is still empty (What, Tested, AI-assisted), as @oneandonlydean asked on Oct 8. Please fill it in. - Say which input needed each new check. A wrong class or machine already fails on main's bounds checks, so without a concrete input that was accepted (or written out) wrongly, these only change the error message. Checks that reject an input main accepted (e.g. `e_version`, `e_ehsize`, ident version) are the ones worth keeping; show it with a case that passes on main. - Overlap with #2262, which edits the same `ReadHeader` lines and the same `test_elf_header.py` (class / data encoding / ident version). Whichever lands first conflicts the other. Please coordinate: list it under **Depends on**, and either drop the checks #2262 already covers or rebase on it and keep only `machine`, `version` and `header size`. - Please check the new message wording against #2262's after the rebase so the two don't diverge on the same check.
oneandonlydean commented 2026-10-11 08:01:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T08:01:09Z.


Closing: the points from 10-08 and 10-09 are still open, and the branch conflicts with main in test_elf_header.py since #2262. If you decide to continue, please reopen.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106925479 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1087#issuecomment-6106925479). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T08:01:09Z. --- Closing: the points from 10-08 and 10-09 are still open, and the branch conflicts with main in `test_elf_header.py` since #2262. If you decide to continue, please reopen.

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!1087
No description provided.