xmem: check n * PAGE and base + len overflow in XMemMapPhysicalPages (#224) #247

Open
github-bot wants to merge 1 commit from github-bot/gh-247 into main AGit
Owner

@⁠ending3729 on GitHub · 2026-11-26 12:38 UTC · original
ending3729:fix/xmem-map-physical-pages-overflow → main · +21 −2 · 1 files · 1 commits · open

Fixes #224.

What changed

  • crates/victory-hle/src/modules/xmem.rs: in XMemMapPhysicalPages, check n.checked_mul(PAGE) and base.checked_add(len) before std::slice::from_raw_parts(pages, n) and unmap, returning null on overflow.
  • crates/victory-hle/src/modules/xmem.rs: in unmap, check base.checked_add(len) so end cannot wrap.
  • Added unit test modules::xmem::tests::map_physical_pages_rejects_overflowing_count_and_end (verified failing before the fix and passing after).

Tested

  • Windows 11 Build 26100, Ryzen 5 7500F, AMD Radeon RX 6600 XT 8 GB, Rust 1.98.1
  • cargo test -p victory-hle --locked: 156 passed, 0 failed, 2 ignored; no_dll_planting: 1 passed, 0 failed
  • cargo test -p xtask --locked: 9 passed, 0 failed
  • cargo clippy -p victory-hle --all-targets --locked --no-deps -- -D warnings: 0 warnings
  • Not tested: live GTA VI title run (no local game dump)

AI use

  • Antigravity (Gemini 4 Neon) assisted with code inspection, patch authoring, and local test verification.
**@⁠ending3729** on GitHub · 2026-11-26 12:38 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/247) `ending3729:fix/xmem-map-physical-pages-overflow` → `main` · +21 −2 · 1 files · 1 commits · open Fixes #224. **What changed** - `crates/victory-hle/src/modules/xmem.rs`: in `XMemMapPhysicalPages`, check `n.checked_mul(PAGE)` and `base.checked_add(len)` before `std::slice::from_raw_parts(pages, n)` and `unmap`, returning null on overflow. - `crates/victory-hle/src/modules/xmem.rs`: in `unmap`, check `base.checked_add(len)` so `end` cannot wrap. - Added unit test `modules::xmem::tests::map_physical_pages_rejects_overflowing_count_and_end` (verified failing before the fix and passing after). **Tested** - Windows 11 Build 26100, Ryzen 5 7500F, AMD Radeon RX 6600 XT 8 GB, Rust 1.98.1 - `cargo test -p victory-hle --locked`: 156 passed, 0 failed, 2 ignored; `no_dll_planting`: 1 passed, 0 failed - `cargo test -p xtask --locked`: 9 passed, 0 failed - `cargo clippy -p victory-hle --all-targets --locked --no-deps -- -D warnings`: 0 warnings - Not tested: live GTA VI title run (no local game dump) **AI use** - Antigravity (Gemini 4 Neon) assisted with code inspection, patch authoring, and local test verification.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:41:34 +00:00
Author
Owner

@⁠lerapeurdu62280-debug on GitHub · 2026-11-26 14:16 UTC · original · approved these changes

Read the diff. checked_mul/checked_add before from_raw_parts and in unmap close a real wrap on title-supplied n/address, and the test covers both the count and the end overflow.

**@⁠lerapeurdu62280-debug** on GitHub · 2026-11-26 14:16 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/247#pullrequestreview-6075636017) · **approved these changes** Read the diff. checked_mul/checked_add before from_raw_parts and in unmap close a real wrap on title-supplied n/address, and the test covers both the count and the end overflow.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/247/head:github-bot/gh-247'
git switch 'github-bot/gh-247'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-247'
git switch 'github-bot/gh-247'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-247'
git switch 'github-bot/gh-247'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-247'
git switch 'main'
git merge --squash 'github-bot/gh-247'
git switch 'main'
git merge --ff-only 'github-bot/gh-247'
git switch 'main'
git merge 'github-bot/gh-247'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.