HLE: guard zero-length range panic in xmem::aliases and map/unmap size overflows #2552
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2552
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2552/head"
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?
@reeledMarek on GitHub · 2026-11-25 15:40 UTC · original
reeledMarek:fix/hle-xmem-aliases-and-overflow→main· +35 −9 · 1 files · 1 commits · closed without mergingProblem
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.@Marvisak on GitHub · 2026-11-25 18:36 UTC · original
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
@reeledMarek on GitHub · 2026-11-25 20:05 UTC · original
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