Shaders: reject DXBC part offsets inside the header or part table #3249
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3251"
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 andrewpozdnakov7-jpg on 2026-11-26T14:38:04Z.
Container::parsereads each part offset from the table and uses it without checking that it lies past the header and the table itself. An offset of 0 reads the container magic back as a part FourCC (DXBC), and an offset inside the table reads neighbour entries as a part header.The table has to fit inside the container, and every part now has to start at or after
HEADER_SIZE + 4 * count. Anything earlier isMalformed("part offset inside the header or part table").rejects_part_offsets_inside_the_header_or_tablecovers offset 0 and an offset landing inside the table;cargo test -p victory-shader --lib dxbc: 3 passed.victory-shadersuite with app-local WARP SM 6.6 and active DXIL validation: 300 passed, 3 failed, 3 ignored. The same three fail on63bcca4without this change (299 passed, 3 failed, 3 ignored):wave64_permutes_stay_within_each_32_lane_half,permutes_read_the_lane_named_and_zero_from_lanes_left_out,edge_flagged_triangles_draw_as_unflagged_ones, allwarpassertions this machine produces.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Valid containers are unaffected: every real part starts after the table, which the round-trip test keeps covering.
Fixes #777.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T14:49:53Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64:
ejects_part_offsets_inside_the_header_or_table).
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T22:29:00Z.
Review: APPROVED
Verified on
8d5898b7:rustfmt --edition 2024 --check crates/victory-shader/src/dxbc.rs: clean.cargo xtask policy:191 files ok.cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features): clean.cargo test --locked -p victory-shader --lib dxbc::: 3 passed, 0 failed (includingrejects_part_offsets_inside_the_header_or_table).With
count <= 256,table_end = HEADER_SIZE + 4 * count(<= 1,056) cannot overflow,data.len() < table_endrejects truncated part tables against the declared container slice, andoffset < table_endcleanly rejects offsets pointing into the 32-byte header or part table while keeping zero-part containers and parts starting attable_endworking. (Minor non-blocking note: adding a unit test wheredata.len() < table_endand using checked additions onoffset + 4/offset + 8 + sizeatdxbc.rs:102, 109for 32-bit targets would harden the remaining boundary paths.) LGTM.Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:29:04Z.
Windows 11,
63bcca4+ this PR:cargo test -p victory-shader --lib dxbc::: 3 passed / 0 failed.dxbc::tests::rejects_part_offsets_inside_the_header_or_tableby name: 1 passed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.The test covers both the offset that names the container magic (
0, which the old parser read back as theDXBCpart FourCC) and an offset inside the part table, each expectingShaderError::Malformed("part offset inside the header or part table"). Synthetic only. AI-assisted.Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T23:02:33Z.
NVIDIA full-suite run, to go with the reports above by Dukestar69, Jackster, fuzeofficlal, since none of them names a GPU run. Tested exact head
8d5898b(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: 867 passed, 0 failed, 10 ignored.rejects_part_offsets_inside_the_header_or_table.--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
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T01:23:15Z.
Independent local verification of PR #3251 (head
8d5898b7f6f57135bc0ed258a8fec995546f94d4), Windows / Rust 1.100.0 / MSVC, worktree-localCARGO_TARGET_DIR,CARGO_BUILD_JOBS=2, synthetic source only, no game data.Command:
cargo test --locked -p victory-shader --lib -- dxbc::tests::rejects_part_offsets_inside_the_header_or_table --exact --test-threads=1 --quietResult:
running 1 test,test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out.git diff --check 63bcca43c6a00a758510398fa43096ce7e4f7df0 HEAD(the real merge base) exits 0. The new test name is absent fromorigin/main(git grepfound 0 hits), confirming the test is added by this PR. Against currentorigin/mainan unrelated trailing blank line incrates/victory-formats/src/xma/tables.rspollutesdiff --check, so the merge base was used.Only the named test was run; the full crate suite was not exercised. GPU/driver: N/A (CPU-only shader parsing). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM were used.
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.