Shaders: guard VsInput VGPR and PS root SGPR additions against overflow in io::raise #3076
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!3076
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3076"
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?
@Dukestar69 on GitHub · 2026-11-26 06:42 UTC · original
Dukestar69:fix/io-raise-checked-registers→main· +43 −2 · 1 files · 1 commits · closed without mergingSummary
Guards two unchecked register-index additions in
io::raise(crates/victory-shader/src/io.rs) against integer overflow on malformed or boundary FSSM shader metadata:StageIo::Vs(i.vgpr + channel): useschecked_add(channel)and returnsShaderError::Malformed("vertex input VGPR out of bounds")instead of panicking in debug builds or wrapping ontov0..=v2(VertexId/PrimitiveId) in release builds whenvgpr >= 253andmasksets an overflowing channel.StageIo::Ps(u32::from(r.user_data) + r.sgprs): usessaturating_add(r.sgprs)so largesgprscounts in root parameters cannot overflowu32(or wrap below the.clamp(8, 104)upper bound in release builds).Verification
io::tests::raise_handles_extreme_vs_vgpr_and_ps_root_sgprs_without_overflow:63bcca4(panicked at crates/victory-shader/src/io.rs:239:41: attempt to add with overflow).cargo test -p victory-shader io::tests: 5 passed, 0 failed.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).
@fuzeofficlal on GitHub · 2026-11-26 08:03 UTC · original · approved these changes
Tested locally on Windows 11 x64 (
rustc 1.98.1):cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean.cargo test -p victory-shader --locked io::tests: 5 passed, 0 failed.The VS
checked_addcleanly rejectsu8register-number overflow while preservingv255as a valid single-channel input, and saturatingu32::from(r.user_data).saturating_add(r.sgprs)before.clamp(8, 104)produces the exact10..=106initialized SGPR count expected byLower::inputs. The regression test covers both overflow cases. LGTM.@Marvisak on GitHub · 2026-11-26 08:22 UTC · original
Automated triage for the maintainers.
Proposed close: this guards cases that valid shader metadata cannot produce. In
io::raise,i.vgpr + channelcan only overflow when a vertex input starts at v253 or higher and still has a channel past v255, which is past the 256-VGPR file.u32::from(r.user_data) + r.sgprscan only overflow when a root parameter claims about 4 billion user SGPRs, and the result is clamped to 104 anyway. The new test builds exactly these records by hand (vgpr: 255,sgprs: u32::MAX). No real metadata reaches them. CI: not run.Evidence that a real FSSM record reaches either path (for example a parser path that yields such values from well-formed data) would change this verdict.
This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code
@Dukestar69 on GitHub · 2026-11-26 09:32 UTC · original
Closing per triage feedback: valid FSSM metadata cannot produce the overflowing
vgprorsgprsvalues guarded here. Thanks for the review! Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).Pull request closed