victory-shader: clamp LDS indexes and drop out-of-bounds writes #618
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!618
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-618"
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?
@SalmanBarkat on GitHub · 2026-11-27 14:17 UTC · original
SalmanBarkat:fix/ds-oob-lds-clamp→a-publier· +177 −22 · 2 files · 2 commits · openOut-of-bounds local data share (LDS) byte offsets previously wrapped or accessed outside the declared groupshared array bounds in emitted DXIL.
Summary
@gut0to on GitHub · 2026-11-27 15:00 UTC · original · reviewed
AI-assisted static review; I traced the LDS address calculation and bounds predicate in this diff. I did not run the test suite.
@ -5592,3 +5591,4 @@let dword = |l: &mut Self, bytes: u32| -> (V, V) {let c = l.cur;let o = l.s.m.i32(bytes);let at = l.s.m.bin(c, Bin::Add, a, o);@gut0to on GitHub · 2026-11-27 15:00 UTC · original
AI-assisted review: the bounds check runs after
a + byteshas already wrapped in 32-bit arithmetic. For a multi-dword access starting at0xFFFF_FFFC, the second dword wraps to index 0 and passesinside, so an out-of-range read can return LDS[0] and a write can clobber it. Could the code detect addition overflow (or widen the sum) before clamping? Please add a boundary case for a multi-dword access at this address.@lvndrpup on GitHub · 2026-11-27 15:38 UTC · original · reviewed
Tested on an RTX 3060 Ti (Windows 11, debug build), base
4eb6cfdagainst head501fb5d.4eb6cfd501fb5dlds_out_of_bounds_reads_zero_and_drops_writes, copied onto baseds_write_b32thends_read_b32at one address (64 threads, 512 bytes of LDS)0x200to0xFFFFFFFC, on the card and on WARPds_read_b32at0x2000x20(WARP skips it: no 32-lane waves)0x20cargo test -p victory-shader --libcargo clippy -p victory-shader --all-targets -- -D warnings, with and without--all-featuresTwo things:
lds_bytes, butinsidecompares withs.lds_dwords. For a console wave64 program in host waves of 32,lower.rsadds dwords after the title's LDS: thewave_basecounter (halves, line 1948) and the exchange pair (line 1902). An access at the title'slds_bytesis then "inside" and reaches them. The third row shows it: the read at0x200returns 32, the counter after one host wave's atomic add, where the console gives 0. A write there would land on those dwords instead of being dropped. Bounding against the title's own size (cs.lds_bytes() / 4, before those dwords are added) would cover it. NVIDIA runs wave64 programs this way, so this is the case that matters on that hardware.The probe, in
valu_tests.rs.build_cs64is a copy ofbuild_cswithwave64: true:It conflicts with #623, #611, #578 and #502, all in
valu_tests.rs. With #623, both PRs add a test at the end of the file.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.