loader: validate relocation symbol index and segment file size #1369

Closed
github-bot wants to merge 1 commit from gh-pr/1369/head into gh-pr/1369/base
Owner

@⁠HamsterCL on GitHub · 2026-10-10 12:51 UTC · original
HamsterCL:fix/relocation-symbol-bounds → main · +5 −1 · 1 files · 1 commits · closed without merging

Summary

  • `GetRelocationInfo` indexed the symbol table with the symbol number from the relocation entry without a bound; it now exits if the index is outside the table declared by `DT_OS_SYMTABSZ`.
  • `LoadProgramToMemory` trusted `p_filesz <= p_memsz` when copying a segment; it now exits if a segment claims more file data than memory.

Small, self-contained change in `src/loader/runtimeLinker.cpp` (+6/-0 effectively), split out of the closed #1329.

**@⁠HamsterCL** on GitHub · 2026-10-10 12:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1369) `HamsterCL:fix/relocation-symbol-bounds` → `main` · +5 −1 · 1 files · 1 commits · closed without merging ## Summary - \`GetRelocationInfo\` indexed the symbol table with the symbol number from the relocation entry without a bound; it now exits if the index is outside the table declared by \`DT_OS_SYMTABSZ\`. - \`LoadProgramToMemory\` trusted \`p_filesz <= p_memsz\` when copying a segment; it now exits if a segment claims more file data than memory. Small, self-contained change in \`src/loader/runtimeLinker.cpp\` (+6/-0 effectively), split out of the closed #1329.
GetRelocationInfo indexed the symbol table with the symbol number from the
relocation entry without a bound; exit if it is outside the table declared
by DT_OS_SYMTABSZ. LoadProgramToMemory also trusted p_filesz <= p_memsz when
copying a segment, so exit if a segment claims more file data than memory.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:54:36 +00:00
github-bot closed this pull request 2026-11-26 09:54:36 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-10 12:54 UTC · original · edited 2026-10-10 12:59 UTC

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 889affb4-5c51-4ddf-ae4e-ee7910507b5b


📥 Commits

Reviewing files that changed from the base of the PR and between 307fdcf7ad and 948ef426a5.



📒 Files selected for processing (1)
  • src/loader/runtimeLinker.cpp


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




📝 Walkthrough
📝 Walkthrough

Walkthrough

The loader rejects relocations when the dynamic symbol table is absent or the symbol index is out of bounds. It also rejects ELF load segments when the file size exceeds the memory size.

Suggested reviewers: nmzik



Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 948ef

The change adds bounds checks for malformed relocation and segment data. No concrete merge-blocking risk is established.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed No active directly linked issue remains. Issue #1329 is closed and supplies historical context only. Therefore, this pull request has no active linked-issue coding requirements.
Out of Scope Changes check Passed The reported changes are limited to validation in src/loader/runtimeLinker.cpp: relocation symbol-table bounds checking and p_filesz versus p_memsz checking. These changes match the historical l…
Title check Passed The title clearly and concisely describes both validation changes in the loader.
Description check Passed The description accurately explains the relocation symbol-index and segment file-size validations in the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-10 12:54 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1369#issuecomment-6097715126) · edited 2026-10-10 12:59 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1369?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `889affb4-5c51-4ddf-ae4e-ee7910507b5b` <hr> </dd> </dl> <hr> </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> <dl> <dd> Reviewing files that changed from the base of the PR and between 307fdcf7ad5d9d15b5966288fcc598ac9dbca188 and 948ef426a5f7c8a4b35d39f2d8483eacfbb0559e. <hr> </dd> </dl> <hr> </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (1)</strong></summary> <dl> <dd> <dl> <dd> * `src/loader/runtimeLinker.cpp` <hr> </dd> </dl> <hr> </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. <hr> </dd> </dl> <hr> </dd> </dl> </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> ## Walkthrough The loader rejects relocations when the dynamic symbol table is absent or the symbol index is out of bounds. It also rejects ELF load segments when the file size exceeds the memory size. **Suggested reviewers:** `nmzik` <hr> </dd> </dl> </details> <hr> </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"948ef426a5f7c8a4b35d39f2d8483eacfbb0559e" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `948ef` <!-- final_review_risk_coverage:{"sourceCommitId":"948ef426a5f7c8a4b35d39f2d8483eacfbb0559e","coveredCommitId":"948ef426a5f7c8a4b35d39f2d8483eacfbb0559e","kind":"reviewed"} --> The change adds bounds checks for malformed relocation and segment data. No concrete merge-blocking risk is established. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v1.svg" width="14" height="17" align="middle" alt="Passed" title="Passed"></picture></sup> 4 | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v1.svg" width="14" height="17" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | No active directly linked issue remains. Issue `#1329` is closed and supplies historical context only. Therefore, this pull request has no active linked-issue coding requirements. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The reported changes are limited to validation in `src/loader/runtimeLinker.cpp`: relocation symbol-table bounds checking and `p_filesz` versus `p_memsz` checking. These changes match the historical l… | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes both validation changes in the loader. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description accurately explains the relocation symbol-index and segment file-size validations in the changeset. | </dd> </dl> </details> <hr> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1369)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) <hr> </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.