Shaders: bound a signature part's register rows and its allocation #1823
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!1823
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1823"
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?
@slatefield on GitHub · 2026-11-24 23:02 UTC · original
slatefield:shader/signature-part-bounds→main· +43 −1 · 1 files · 2 commits · openA signature part's element register comes from the part's own bytes and goes through
container.rsasr as u8, and the row count is counted in a byte for PSV0, so a register above 254 is truncated silently. That one is a real bound; it is refused now, withu32::MAX(an unallocated row) still accepted.Second, the element count read from the part no longer sizes a
Vecdirectly:Vec::with_capacity(count.min(part.len() / 32)). No new error comes with it; a count past the part's rows still fails where a row is read, with the existingMalformed("truncated").Both are in
signature()incrates/victory-shader/src/emit/mod.rs, with tests for the register bound and for the truncated read.Checked here:
cargo test -p victory-shader --lib120 passed, 1 ignored; Windows-target clippy--all-targets --all-featuresclean. sinan-cmyk ran the program-by-program comparison on the retail pack atmain940d32f: 23,917 validated on both, no failure reason changes, so the bounds reject nothing on real data.This is the trimmed version: the earlier row-mask check and the up-front count error were removed after triage, as they only mattered for damaged input.
@DesertGamer on GitHub · 2026-11-24 23:06 UTC · original
VIctory V2: community PRs, merged and tested
Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.
Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).
⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.
Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2
Unofficial community fork of Marvisak/VIctory, GPL-3.0.
@Marvisak on GitHub · 2026-11-25 06:31 UTC · original · edited 2026-11-25 14:51 UTC
Automated triage for the maintainers.
Merge candidate (small).
signatureincrates/victory-shader/src/emit/mod.rsnow refuses an element whose register is above 254 (an unallocatedu32::MAXis still accepted). It also sizes itsVecbycount.min(part.len() / 32)instead of the raw count. The register bound has a real basis:container.rswrites the start row asr as u8and counts the signature's vectors in a byte for PSV0, so a larger register would be truncated silently. The capacity clamp is a one-line change with no new error: a count past the part's bytes still fails on the row read withMalformed("truncated"), as the new test checks.On your reply: thanks, this is the trimmed version that was asked for. The mask check is gone, and the register bound and its test are kept. The clamp is fine to keep. The PR description still mentions the mask check, so please update it before merge.
CI: no check runs on the head commit.
Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 12:24 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
60561410ontomain940d32f(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,917 onmain, 23,917 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).
@slatefield on GitHub · 2026-11-25 12:59 UTC · original
Trimmed as asked, in
4fe6ddaon the branch:Vec::with_capacity(count.min(part.len() / 32)). No new error for it; a count past the part still fails on the row read with the existingMalformed("truncated").cargo test -p victory-shader --lib: 120 passed, 1 ignored. Windows-target clippy--all-targets --all-features: clean. The PR now rejects nothing thatmainaccepts, which matches sinan-cmyk's program-by-program count on the retail dump (23,917 validated on both).If the capacity clamp alone still feels like it is guarding input the title cannot produce, say so and I will drop it too; the register bound is the only part I would defend as a real fix.
@Melow-code on GitHub · 2026-11-24 23:08 UTC · original · requested changes
The count bound is correct. The mask check has a gap:
mask.count_ones() > 4stops the1u8 << colsoverflow but does not refuse bits above w. A mask like0x10or0xF0passes:col = trailing_zeros().min(3)clamps the element to w silently.colscan be 4 withcol3, and the rebuilt mask in container.rs becomes0x78— outside the four components.Fix:
if mask & 0xF0 != 0 { return Err(...) }before the loop. A test with mask0x10would cover it.@catminou4 on GitHub · 2026-11-24 23:52 UTC · original · approved these changes
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
70564ae), cargo test -p victory-shader --locked → 120 passed, 0 failed. GPU execution tests are #[cfg(all(test, windows))] and run only on Windows.Signature part rows bounded by the…: row-bound validation in structure/lower paths.
@Melow-code on GitHub · 2026-11-25 11:54 UTC · original · requested changes
The count bound is correct.
count > part.len().saturating_sub(base) / 32also refuses abasepast the end. After the check,base + 32 * istays in the part.One gap in the mask check.
mask.count_ones() > 4stops the1u8 << colsoverflow, but it does not refuse bits above w. A damaged mask such as0x10or0xF0passes:colistrailing_zeros().min(3), so the clamp moves the element to w without an error.colscan be 4 withcol3, and then the rebuilt mask incontainer.rsis0x78, which is outside the four components.if mask & 0xF0 != 0refuses all of these cases and also prevents the overflow. A test with0x10would cover it.The register bound (at most 254, or
u32::MAXfor no register) agrees with a PSV0 row count held in a byte.@fuzeofficlal on GitHub · 2026-11-26 18:47 UTC · original · approved these changes
Verified
4fe6dda5f507f66f1221ebc99e1a358f1ce809d1cleanly merged ontomain(63bcca43) on Windows 11 x64:signature(crates/victory-shader/src/emit/mod.rs:548, 620-622) cleanly bounds initialVecallocation bypart.len() / 32and rejectsregister > 254(keepingu32::MAXfor unallocated rows) to match PSV0'su8row-count encoding.cargo test -p xtask --locked policy::tests::repository_passes_policy:1 passed(asset 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 emit::tests:::19 passed, 0 failed(a_signature_count_past_its_rows_is_refusedanda_signature_register_outside_its_field_is_refusedpass).Minor doc/test notes (non-blocking): worth updating the PR description to drop mention of the removed mask check, and optionally pinning the exact
254/255register boundary. Ready to merge.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.