HLE: guard zero-length range panic in xmem::aliases and map/unmap size overflows #2550
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2552"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T15:40:12Z.
Problem
xmem::aliases(at, len, out)computedend = at.saturating_add(len)and passedat.saturating_add(1)..endtoBTreeMap::range. Whenlen == 0(orat == usize::MAX),start > endunconditionally panicked insideBTreeMap::range.XMemMapPhysicalPagescomputed uncheckedn * PAGE, andunmapcomputed uncheckedbase + lenandbase + 1..end.Fix
end <= atinaliasesandend <= baseinunmap(usingsaturating_add(1)for the range start).n.checked_mul(PAGE)andbase.checked_add(bytes)inXMemMapPhysicalPages, returning null on overflow.Testing
aliases_and_map_reject_zero_length_and_overflowing_rangesincrates/victory-hle/src/modules/xmem.rs.cargo test -p xtask --lockedpasses asset policy.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T18:36:48Z.
Automated triage for the maintainers.
This adds zero-length and overflow guards to
aliases,unmapandXMemMapPhysicalPagesincrates/victory-hle/src/modules/xmem.rs. The guards cover cases that cannot occur:xmem::aliaseshas no caller inmainexcept the module's own test, which passesPAGE.unmapalready returns early forlen == 0.n * PAGEto overflow inXMemMapPhysicalPages, the title would have to pass more than 2^48 pages. That call is already invalid at thefrom_raw_parts(pages, n)that follows.usize::MAXare not user-mode addresses.The rest is reformatting. CI passes (
check).Proposed for closing as no value: it guards cases that cannot occur. The PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. A caller that really passes a zero length or an overflowing count, with the path that reaches it, would change this.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T20:05:44Z.
Closing per triage — agreed these guards cover unreachable cases (
aliasesonly called from tests withPAGE,unmapalready checkslen == 0, impossible page counts). Thanks for the review!Pull request closed