GPU/list+draw: fix integer overflows and unchecked buffer bounds in resolve_queries, execute_indirect, and rectangles #480
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!480
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-480"
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?
@AscilCH on GitHub · 2026-11-25 01:22 UTC · original
AscilCH:fix/gpu-command-bounds-overflow-checks→main· +186 −13 · 2 files · 1 commits · openProblem
Three GPU command-recording bounds checks in
crates/victory-gpu/src/list.rsandcrates/victory-gpu/src/draw.rsused unchecked or narrow integer arithmetic:list::resolve_queries(list.rs:1362):if offset + u64::from(count) * bytes > sizeused uncheckedu64arithmetic. A largeoffset(e.g.u64::MAX - 4withcount = 1) panicked in debug builds and wrapped around in release builds to pass the guard, callingdata.add(offset as usize)+defer_writeout of bounds.list::execute_indirect(list.rs:1696-1697):buffer_bytes(arguments).map(|(p, _)| p as u64 + offset)andbuffer_bytes(count).map(|(p, _)| p as u64 + count_offset)discarded buffersizecompletely and used unchecked+, allowing out-of-bounds or wrapping offsets to reach into an adjacent buffer'sShadow.draw::State::rectangles(draw.rs:2181-2189, 2212):u64::from(first + count) * stride > u64::from(v.size)addedfirst + countinu32before widening tou64(wrapping to0on e.g.0x8000_0000 + 0x8000_0000), computedv.address + u64::from(first) * strideunchecked, and truncated(rects * 6 * stride) as u32intoSizeInBytes.Fix
checked_mulandchecked_addinlist::resolve_queries.checked_buffer_offset(buffer, offset, len)inlist.rsand validate botharguments(stride * max.max(1)) andcount(4) against their buffer sizes inexecute_indirect.rect_vertex_spanindraw.rswideningu64::from(first) + u64::from(count), using checked arithmetic for address/byte spans, and validatingu32::try_from(dst_bytes).resolve_queries_and_execute_indirect_reject_overflowing_offsetsandrect_vertex_span_rejects_overflow_and_out_of_bounds.Verification
cargo test -p victory-gpu --locked list::tests -- --test-threads=1: 2 passed, 0 failedcargo test -p victory-gpu --locked draw::tests -- --test-threads=1: 1 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-gpu --all-targets --locked -- -D warnings: cleancargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit tests only, no game data.)
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.