Check pipeline stream subobject bounds #1524
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1524"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by Gauss999 on 2026-11-28T21:14:44Z.
Summary
keep.lostand stop before reading outsideSizeInBytes.Tests
No local build or tests were run. CI depends on maintainer approval; no CI results are available yet.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by babuakhil on 2026-11-28T22:09:44Z.
Built and ran this on Windows, since it hadn't been run yet: Windows 11, Rust 1.98.1 (pinned), applied on current
main(d4b5d51); cherry-picks cleanly. Clippy reports nothing inpso.rs.Heads-up for CI:
replayis#[cfg(all(windows, feature = "diagnostics"))], so these tests only build with--features diagnostics. CI'scargo test --workspace --lockedruns without it and won't run them. With the feature, all threereplay::psotests pass.The out-of-bounds read is real and fixed. I fed
streama few hand-made streams from a throwaway test (not part of this PR):mainSizeInBytes = 4(payload past the end)5)DXGI_SAMPLE_DESC),SizeInBytes = 16SizeInBytes = 12(complete, no trailing padding)SizeInBytes = 20(last one complete, unpadded)One problem: the last two rows.
subobject_boundsrequires the aligned end (next) to fit, so a last subobject whose payload ends on a 4-byte boundary (DXGI_SAMPLE_DESC;D3D12_BLEND_DESCandDEPTH_STENCIL_DESC1end the same way) is dropped whenSizeInBytesdoesn't include the trailing pad, although every byte read is inside the stream. Streams built from d3dx12-stylealignas(void*)subobjects are padded, so this may never happen with the title's streams, but it is a change frommainbeyond the bounds fix.Checking the payload's end and using
nextonly to advance keeps the fix and accepts those:The loop's
at + 4 <= SizeInBytescheck already ends the walk whennextruns past the end.subobject_bounds(0, 4, 4, 7)staysNone(the payload ends at 8), and the overflow cases still returnNonefrom thechecked_adds.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Gauss999 on 2026-11-28T22:45:18Z.
Thanks @babuakhil for validating this on Windows and catching the unpadded-final-subobject regression.
subobject_boundsnow computesvalueandendwith checked arithmetic and checks onlyend <= stream_size. The alignednextcalculation also remains checked, butnextmay extend past the stream and is used only for advancement; the existing loop condition ends the walk before another read.I added a decoding regression for a final kind 17 /
DXGI_SAMPLE_DESCwithSizeInBytes = 12: its complete 8-byte payload is accepted without trailing padding and decoded with no loss reported. The bounds regression also checks(value, next) == (4, 16)for that case, while the truncated-payload case and all payload/alignment overflow cases still returnNone.I reviewed the resulting diff; only
crates/victory-gpu/src/replay/pso.rschanged. I have not run the Windows-only tests locally.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by babuakhil on 2026-11-28T23:04:00Z.
Re-checked with
b53b952ond4b5d51(Windows 11, Rust 1.98.1): builds, clippy (--all-features) reports nothing inpso.rs, and with--features diagnosticsall fourreplay::psotests pass,a_complete_unpadded_final_subobject_is_takenamong them (27/27replaytests).The same throwaway streams as before now give:
fad0e0b)SizeInBytes = 4SizeInBytes = 16SizeInBytes = 12SizeInBytes = 20So the out-of-bounds read stays fixed, and the unpadded final subobjects are taken again. Looks good to me.