Shaders: guard VsInput VGPR and PS root SGPR additions against overflow in io::raise #3074
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T06:42:23Z.
Summary
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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T08:03:38Z.
Review: APPROVED
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.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T08:22:12Z.
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
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T09:32:02Z.
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