xmem: use saturating_add for view end bounds in aliases #2413

Open
opened 2026-11-26 05:04:59 +00:00 by github-bot · 1 comment
Owner

@⁠pushkarreddyy on GitHub · 2026-11-25 13:07 UTC · original

Summary

In crates/victory-hle/src/modules/xmem.rs (aliases), end is computed with at.saturating_add(len), but the view range checks on lines 412 and 417 compute *base + size and base + size with unchecked addition, which can overflow/panic if a view's base + size reaches usize::MAX.

Expected

Use saturating_add for base + size in aliases to match at.saturating_add(len).

Claiming this issue and opening a PR with unit tests shortly.

**@⁠pushkarreddyy** on GitHub · 2026-11-25 13:07 UTC · [original](https://github.com/Marvisak/VIctory/issues/2413) ### Summary In `crates/victory-hle/src/modules/xmem.rs` (`aliases`), `end` is computed with `at.saturating_add(len)`, but the view range checks on lines 412 and 417 compute `*base + size` and `base + size` with unchecked addition, which can overflow/panic if a view's `base + size` reaches `usize::MAX`. ### Expected Use `saturating_add` for `base + size` in `aliases` to match `at.saturating_add(len)`. *Claiming this issue and opening a PR with unit tests shortly.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:04:59 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:47 UTC · original

Automated triage for the maintainers.

Read against main (da82e44): in crates/victory-hle/src/modules/xmem.rs, physical.views only gets an entry after MapViewOfFile3 has mapped len bytes at base and the result was checked (end of the view-mapping function, physical.views.insert(base, (len, slice))). So every (base, size) that aliases reads is a live range of the host process's user address space, and base + size stays far below usize::MAX. at + len comes from the caller, which is why only that sum saturates. The overflow described here cannot happen; switching to saturating_add (open PR #2421) would only be defensive.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:47 UTC · [original](https://github.com/Marvisak/VIctory/issues/2413#issuecomment-7167316255) <!-- victory-issue-triage v1 verdict=answered seen=2026-11-25T13:07:33Z at=2026-11-25T15:46:44Z --> Automated triage for the maintainers. Read against main (da82e44): in `crates/victory-hle/src/modules/xmem.rs`, `physical.views` only gets an entry after `MapViewOfFile3` has mapped `len` bytes at `base` and the result was checked (end of the view-mapping function, `physical.views.insert(base, (len, slice))`). So every `(base, size)` that `aliases` reads is a live range of the host process's user address space, and `base + size` stays far below `usize::MAX`. `at + len` comes from the caller, which is why only that sum saturates. The overflow described here cannot happen; switching to `saturating_add` (open PR #2421) would only be defensive. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#2413
No description provided.