GPU: validate execute_indirect buffer offsets against buffer bounds and u64 overflow #2222
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T08:18:14Z.
Summary
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.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T08:22:47Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):cargo test -p victory-gpu --lib execute_indirect_rejects_overflowing_or_oob_offsets— passed on RTX 5090cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean
buffer_atbounds andu64overflow validation forexecute_indirectbuffer offsets. Looks good.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:48:26Z.
Review: COMMENTED
execute_indirect buffer offsets validated with checked_add against buffer size (u64 wrap / OOB aliasing). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Good defensive fix, includes a unit test for overflowing offsets.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:30:21Z.
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
Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T15:13:57Z.
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.
upstream-sync referenced this pull request2026-11-25 20:06:09 +00:00
upstream-sync referenced this pull request2026-11-26 06:03:43 +00:00
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.