xmem: XMemMapPhysicalPages trusts n (unchecked n * PAGE and slice length) #224

Open
opened 2026-11-26 12:00:26 +00:00 by kekonn · 0 comments
kekonn commented 2026-11-26 12:00:26 +00:00 (Migrated from github.com)
Contributor

Imported from avatarmanz/VIctory-7900XTX. Originally posted by kekonn on 2026-11-26T12:00:26Z.


crates/victory-hle/src/modules/xmem.rs:1198 builds the page list with std::slice::from_raw_parts(pages, n), and ~1216 calls unmap(&mut physical, base, n * PAGE). Neither is checked. Release builds don't check for overflow, so n * PAGE and base + len in unmap (~1852) can wrap. XMemAllocatePhysicalPages already uses checked_mul (~651), so this function is the odd one out.

When: only with an absurd n from the title, which a valid title never passes. This is hardening.


Generated by Claude Code

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6626190660 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/issues/224). Originally posted by [kekonn](https://github.com/kekonn) on 2026-11-26T12:00:26Z. --- `crates/victory-hle/src/modules/xmem.rs:1198` builds the page list with `std::slice::from_raw_parts(pages, n)`, and ~1216 calls `unmap(&mut physical, base, n * PAGE)`. Neither is checked. Release builds don't check for overflow, so `n * PAGE` and `base + len` in `unmap` (~1852) can wrap. `XMemAllocatePhysicalPages` already uses `checked_mul` (~651), so this function is the odd one out. **When:** only with an absurd `n` from the title, which a valid title never passes. This is hardening. --- _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
avatarmanz/VIctory-7900XTX#224
No description provided.