Shaders: reject a dxbc part inside the header or part table #1944
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!1944
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1944"
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?
@imjustprism on GitHub · 2026-11-25 01:32 UTC · original
imjustprism:fix/dxbc-part-inside-table→main· +18 −0 · 1 files · 1 commits · opena part offset that points into the container header or the offset table was accepted: offset 0 came back as a part with the container magic as its fourcc. parts follow the table, so an offset before its end is now refused as malformed. #343 refuses parts that overlap each other, which does not catch this.
the reporter had the same check on a fork and could not open a pull request; this one is written against current main, with a test for the header case and the table case. both fail without the check.
fixes #777
@Headache3318 on GitHub · 2026-11-25 01:35 UTC · original
Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head
cba87aeapplied cleanly onto currentmainccfb029.cargo test -p victory-shader --locked: 145 passed, 0 failed, 2 ignored. All tests pass.cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: 4 errors in test code (unused imports, unused variable, dead fieldrovs), but these are pre-existing on main — they fail identically onccfb029without this PR. The PR introduces no new clippy warnings.Not tested: Windows MSVC build, the title itself. AI-assisted.
@Marvisak on GitHub · 2026-11-25 08:20 UTC · original
Automated triage for the maintainers.
Merge candidate.
Container::parseincrates/victory-shader/src/dxbc.rsnow refuses a part whose offset lies before the end of the offset table (HEADER_SIZE + 4 * count). This fixes #777, which is labelled confirmed.On
main, offset 0 is accepted as a part taggedDXBC. The new test covers both the header case and the table case and checks the exact error. It uses the existingbuildhelper. The table itself is already bounds-checked byu32_aton the slice cut to the container's size, so this is the remaining gap from #777.CI:
checkpasses.Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 11:16 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
afc4f791ontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@fuzeofficlal on GitHub · 2026-11-26 01:02 UTC · original
Code review and Windows 11 verification at head
afc4f79123a7merged cleanly ontomain(63bcca43c6a0):crates/victory-shader/src/dxbc.rs:88-95):count <= MAX_PARTS(256) before computingtable_end = HEADER_SIZE + 4 * count(bounded<= 1056, overflow-free), letsu32_atreject truncated tables, and rejects any part withoffset < table_end("part inside the header or table"). Subsequentdata.get(...)bounds checking remains intact.cargo xtask policy:191 files ok;cargo clippy --locked -p victory-shader --tests -- -D warnings: 0 warningsvictory-shader --lib -- dxbc::: 3/3 passed (includingrejects_a_part_inside_the_header_or_the_part_table).LGTM.
reject a dxbc part inside the header or part tableto Shaders: reject a dxbc part inside the header or part table@catminou4 on GitHub · 2026-11-25 03:05 UTC · original · approved these changes
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.145 passed / 0 failed / 2 ignored. DXBC parts inside the header/part table rejected (+1 test) — container-validation hardening against malformed shaders.
@fuzeofficlal on GitHub · 2026-11-26 13:24 UTC · original · approved these changes
Reviewed and verified
afc4f79123a7and merged ontoorigin/main(63bcca43; cleangit merge-tree):crates/victory-shader/src/dxbc.rs:86-95is right: withcount <= MAX_PARTS(256),table_end = HEADER_SIZE + 4 * countcannot overflow, and rejectingoffset < table_endprevents parts from aliasing the DXBC header or offset table while keepingcount == 0,offset == table_end, and zero-length part bodies valid. The new regression test covers both header and table offsets. (Existingoffset + 4/offset + 8 + sizearithmetic could move to checked addition in a follow-up if 32-bit overflow-checked builds are targeted.)Local verification:
rustfmt --edition 2024 --check crates/victory-shader/src/dxbc.rs,xtask policy(182 files ok),cargo clippy -p victory-shader --all-targets(defaultand--all-features),dxbc::tests (3 passed), and the merged non-GPUvictory-shaderunit suite (162 passed, 0 failed, 2 ignored) all pass.LGTM.
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.