Shaders: reject DXBC part offsets inside the header or part table #3251

Open
github-bot wants to merge 1 commit from github-bot/gh-3251 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 14:38 UTC · original
andrewpozdnakov7-jpg:fix/777-dxbc-part-offsets → main · +33 −0 · 1 files · 1 commits · open

Container::parse reads 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 is Malformed("part offset inside the header or part table").

  • rejects_part_offsets_inside_the_header_or_table covers offset 0 and an offset landing inside the table; cargo test -p victory-shader --lib dxbc: 3 passed.
  • Full victory-shader suite with app-local WARP SM 6.6 and active DXIL validation: 300 passed, 3 failed, 3 ignored. The same three fail on 63bcca4 without 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, all warp assertions 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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 14:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/3251) `andrewpozdnakov7-jpg:fix/777-dxbc-part-offsets` → `main` · +33 −0 · 1 files · 1 commits · open `Container::parse` reads 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 is `Malformed("part offset inside the header or part table")`. - `rejects_part_offsets_inside_the_header_or_table` covers offset 0 and an offset landing inside the table; `cargo test -p victory-shader --lib dxbc`: 3 passed. - Full `victory-shader` suite with app-local WARP SM 6.6 and active DXIL validation: 300 passed, 3 failed, 3 ignored. The same three fail on `63bcca4` without 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`, all `warp` assertions 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:39:06 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 14:49 UTC · original · approved these changes

Reviewed the diff and verified locally on Windows 11 x64:

  • Validating data.len() >= table_end and offset >= table_end in Container::parse cleanly rejects malformed DXBC part offsets that point into the header or part offset table.
  • cargo test -p victory-shader --lib dxbc:: -- --test-threads=1: 3 passed, 0 failed (including
    ejects_part_offsets_inside_the_header_or_table).
  • 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).

**@⁠Dukestar69** on GitHub · 2026-11-26 14:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/3251#pullrequestreview-6076169768) · **approved these changes** Reviewed the diff and verified locally on Windows 11 x64: - Validating data.len() >= table_end and offset >= table_end in Container::parse cleanly rejects malformed DXBC part offsets that point into the header or part offset table. - cargo test -p victory-shader --lib dxbc:: -- --test-threads=1: 3 passed, 0 failed (including ejects_part_offsets_inside_the_header_or_table). - 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 22:29 UTC · original · approved these changes

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 (including rejects_part_offsets_inside_the_header_or_table).

With count <= 256, table_end = HEADER_SIZE + 4 * count (<= 1,056) cannot overflow, data.len() < table_end rejects truncated part tables against the declared container slice, and offset < table_end cleanly rejects offsets pointing into the 32-byte header or part table while keeping zero-part containers and parts starting at table_end working. (Minor non-blocking note: adding a unit test where data.len() < table_end and using checked additions on offset + 4 / offset + 8 + size at dxbc.rs:102, 109 for 32-bit targets would harden the remaining boundary paths.) LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 22:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3251#pullrequestreview-6081128834) · **approved these changes** 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** (including `rejects_part_offsets_inside_the_header_or_table`). With `count <= 256`, `table_end = HEADER_SIZE + 4 * count` (`<= 1,056`) cannot overflow, `data.len() < table_end` rejects truncated part tables against the declared container slice, and `offset < table_end` cleanly rejects offsets pointing into the 32-byte header or part table while keeping zero-part containers and parts starting at `table_end` working. (Minor non-blocking note: adding a unit test where `data.len() < table_end` and using checked additions on `offset + 4` / `offset + 8 + size` at `dxbc.rs:102, 109` for 32-bit targets would harden the remaining boundary paths.) LGTM.
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 22:29 UTC · original

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_table by 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 the DXBC part FourCC) and an offset inside the part table, each expecting ShaderError::Malformed("part offset inside the header or part table"). Synthetic only. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 22:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3251#issuecomment-7204718701) 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_table` by 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 the `DXBC` part FourCC) and an offset inside the part table, each expecting `ShaderError::Malformed("part offset inside the header or part table")`. Synthetic only. AI-assisted.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 23:02 UTC · original

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 base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo 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.
  • The new tests ran and passed: rejects_part_offsets_inside_the_header_or_table.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#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_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 23:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/3251#issuecomment-7205203061) 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 base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo 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**. - The new tests ran and passed: `rejects_part_offsets_inside_the_header_or_table`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#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_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-27 01:23 UTC · original

Independent local verification of PR #3251 (head 8d5898b7f6f57135bc0ed258a8fec995546f94d4), Windows / Rust 1.100.0 / MSVC, worktree-local CARGO_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 --quiet

Result: 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 from origin/main (git grep found 0 hits), confirming the test is added by this PR. Against current origin/main an unrelated trailing blank line in crates/victory-formats/src/xma/tables.rs pollutes diff --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.

**@⁠cloph-dsp** on GitHub · 2026-11-27 01:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3251#issuecomment-7207245970) Independent local verification of PR #3251 (head `8d5898b7f6f57135bc0ed258a8fec995546f94d4`), Windows / Rust 1.100.0 / MSVC, worktree-local `CARGO_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 --quiet` Result: `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 from `origin/main` (`git grep` found 0 hits), confirming the test is added by this PR. Against current `origin/main` an unrelated trailing blank line in `crates/victory-formats/src/xma/tables.rs` pollutes `diff --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.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3251/head:github-bot/gh-3251'
git switch 'github-bot/gh-3251'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3251'
git switch 'github-bot/gh-3251'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3251'
git switch 'github-bot/gh-3251'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3251'
git switch 'main'
git merge --squash 'github-bot/gh-3251'
git switch 'main'
git merge --ff-only 'github-bot/gh-3251'
git switch 'main'
git merge 'github-bot/gh-3251'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3251
No description provided.