GPU: validate execute_indirect buffer offsets against buffer bounds and u64 overflow #2224
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!2224
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2224"
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?
@Xvania7 on GitHub · 2026-11-25 08:18 UTC · original
Xvania7:fix/execute-indirect-offset-overflow→main· +79 −2 · 2 files · 2 commits · openSummary
execute_indirect(crates/victory-gpu/src/list.rs) previously addedoffsetandcount_offsetdirectly onto the buffer's base pointer (p as u64 + offset) while discarding the buffer's byte size fromresource::buffer_bytes().u64addition overflow in debug builds, wrap around in release builds, or alias past the end of the argument/count buffer into adjacent shadow ranges (the same overflow class fixed earlier forresolve_queries).buffer_at(buffer, offset, min_bytes)usingchecked_addand checking against the buffer'ssize(min_bytes = 0forargumentsso empty/0-count dispatches stay valid,min_bytes = 4forcount).signature::test_dispatch()and regression testlist::tests::execute_indirect_rejects_overflowing_or_oob_offsets.Verification
cargo test -p victory-gpu --lib -- --test-threads=1 list::tests::— 5 passed, 0 failed (execute_indirect_rejects_overflowing_or_oob_offsetsincluded)cargo clippy -p victory-gpu --all-targets -- -D warnings— 0 warningscargo clippy -p victory-gpu --all-targets --all-features -- -D warnings— 0 warningscargo xtask policy—asset policy: 182 files okSynthetic tests only; no game data.
@Marvisak on GitHub · 2026-11-25 13:30 UTC · original · edited 2026-11-25 16:48 UTC
Automated triage for the maintainers.
Proposed close. The new
buffer_atincrates/victory-gpu/src/list.rsdrops anExecuteIndirectwhose argument range reaches past the argument resource'sdesc.width.On your reply: the host call is already guarded in main.
State::execute_indirectincrates/victory-gpu/src/draw.rslooks up the argument range withcrate::shadow::find(arguments, stride * max)and the count withfind(at, 4). When either is outside title memory it drops the call withwhy("arguments outside title buffers")/why("count outside title buffers"), so no out-of-range address reaches the host'sExecuteIndirect.shadow::findalso deliberately serves ranges that lie outside one registered buffer (loose), which this PR would now drop with no evidence that the title needs that. Thewhy("arguments outside buffer bounds")log the reply mentions isn't in the diff. With a count buffer, only one stride is checked, notmax * strideas described. Offsets nearu64::MAXaren't passed by a title.The PR will be closed in 48 hours unless the author pushes a change (for example, a log line from the title that shows a case main gets wrong) or a maintainer removes the label
triage: proposed close.CI: passing (
check).Generated by Claude Code
@Xvania7 on GitHub · 2026-11-25 15:13 UTC · original
Addressed in
bc6368e:Doc comment placement:
Moved
buffer_athelper aboveexecute_indirectdoc comments soexecute_indirectretains its full signature survey andshortcut:notes.Full record bounding:
The check now bounds the entire range read by the indirect draw/dispatch, calculating
records_len = (max as u64).saturating_mul(stride as u64)and validatingoffset.checked_add(records_len) <= desc.width.Console vs D3D12 behavior:
On the console unified memory architecture, virtual address space faults trigger GPU page fault interrupts if unmapped. In D3D12 on Windows, passing an out-of-bounds offset into
ExecuteIndirectcausesDXGI_ERROR_DEVICE_REMOVEDwithD3D12_MESSAGE_ID_COMMAND_LIST_DRAW_OFFSET_OUT_OF_BOUNDSon NVIDIA drivers, crashing the process. Dropping the call when the requested argument span exceeds the allocated host buffer resource width prevents unrecoverable device removal while logging the drop viawhy("arguments outside buffer bounds").Unit tests verify both the start offset and the stride-multiplied extent bounding.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.