Shader dxbc: use checked arithmetic for bounds slicing #3380
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3380"
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 Arkenoz on 2026-11-26T21:04:40Z.
Tracked in #1633.
Problem
u16_at,u32_at, andu64_atincrates/victory-shader/src/dxbc.rscomputedat + 2,at + 4, andat + 8with unchecked addition, panicking on overflow whenatis nearusize::MAXinstead of returningErr(ShaderError::Malformed("truncated")).Container::parsecomputedoffset + 4,offset + 8, andoffset + 8 + sizewith unchecked addition.Changes
u16_at,u32_at, andu64_atto usechecked_add, returningErr(ShaderError::Malformed("truncated"))on overflow or out-of-bounds.Container::parseto usechecked_addfor part header and body bounds, returningShaderError::Malformed("part header out of bounds")/ShaderError::Malformed("part data out of bounds").helpers_overflow_safely,parse_rejects_max_offset_and_size) covering near-max offsets andu32::MAXpart offsets/sizes.Verification
cargo test -p victory-shader dxbc(4 passed)cargo clippy -p victory-shader --all-targets(0 warnings)AI-assisted with Gemini.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T21:07:13Z.
Review: APPROVED
LGTM — verified on Windows against
origin/main(63bcca4).checked_addfor part header/body bounds inContainer::parseand inu16_at/u32_at/u64_atcleanly eliminates arithmetic overflow panics on malformed DXBC containers.cargo test -p victory-shader --lib dxbc:: -- --test-threads=1: 4 passed, 0 failed (includinghelpers_overflow_safelyandparse_rejects_max_offset_and_size).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Arkenoz on 2026-11-26T21:10:23Z.
The CI failure is an unrelated flaky test in
victory-gpu(descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait). Could someone re-run the check?Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T21:23:59Z.
Review: APPROVED
LGTM — verified against
origin/main(63bcca43) on Windows x64.checked_add+.get(..)) acrossContainer::parseandu16_at/u32_at/u64_at(crates/victory-shader/src/dxbc.rs:88-145) prevents input-driven integer overflow and slice panics on both 32-bit and 64-bit targets without rejecting valid DXBC layouts.dxbc::build(dxbc.rs:149),dxil.rs:88, and signature decoding (emit/mod.rs:544, 551, 625) is outside this PR's scope.cargo test --locked -p victory-shader --lib -- --test-threads=1 dxbc::: 4 passed, 0 failed (includinghelpers_overflow_safelyandparse_rejects_max_offset_and_size).cargo clippy -p victory-shader --all-targets --locked -- -D warnings(default and--all-features): clean.cargo xtask policy: 191 files ok;rustfmt --edition 2024: clean.Synthetic tests only; no game data used.
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T07:26:55Z.
NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, since none of them names a GPU run. Tested exact head
c214b33(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 868 passed, 0 failed, 10 ignored.helpers_overflow_safely,parse_rejects_max_offset_and_size.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
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.