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

Open
opened 2026-11-25 13:07:33 +00:00 by pushkarreddyy · 1 comment
pushkarreddyy commented 2026-11-25 13:07:33 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-25T13:07:33Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6605186612 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2413). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-25T13:07:33Z. --- ### 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.*
Marvisak commented 2026-11-25 16:09:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:47:20Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167316255 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2413#issuecomment-7167316255). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:47:20Z. --- <!-- 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)_
Sign in to join this conversation.
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
Marvisak/VIctory#2411
No description provided.