Loader: prevent u64 wraparound in crash::clzero fast-path loop emulation #2555
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!2555
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2555/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/loader-crash-clzero-wrap→main· +37 −0 · 1 files · 1 commits · closed without mergingProblem
In
crash::clzero, both fast-pathclzeroloop emulators advance the cursor withwrapping_add(0x40)and loop untilcursor >= limit. Iflimit > u64::MAX - 0x3f(or the cursor starts within 63 bytes ofu64::MAX), the addition wraps pastu64::MAXback to0..0x3f < limit, causing the loop to zero address0x0and trigger a nested access violation inside the VEH.Fix
limitto be<= u64::MAX - 0x3fbefore entering either fast-path loop; otherwise fall back to single-instructionclzeroemulation so the CPU executes the loop's ownadd/cmp/jb.Testing
emulated_clzero_loop_falls_back_when_limit_would_wrapincrates/victory-loader/src/crash.rs.cargo test -p xtask --lockedpasses asset policy.@Marvisak on GitHub · 2026-11-25 18:37 UTC · original
Automated triage for the maintainers.
This PR adds a guard to the two fast-path loops in
clzero(crates/victory-loader/src/crash.rs) for a cursor or limit within 63 bytes ofu64::MAX. That case cannot come up. The cursor is a user-mode address the title zeroes (zero(context.Rax)would fault long before reaching the top of the address space), and the limit is the end of the title's buffer, which is also a user-mode address. The guard also does not change the outcome. On the fallback path the title's ownadd rax, 0x40/cmp/jbrun on the CPU and wrap the same way, and the nextclzerofault lands in this handler again. So the loop runs the same, just one exception per line. The new test only covers alimit = u64::MAXthat no real loop has.This counts as a guard for a case that cannot occur, so the PR is proposed for closing. It will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. A reproduction where a title really reaches this state would change the verdict.
CI:
checkpassing.Generated by Claude Code
@reeledMarek on GitHub · 2026-11-25 20:05 UTC · original
Closing per triage — agreed user-mode
clzeroloops cannot wrapu64::MAXin practice. Thanks for the review!Pull request closed