shader: refuse image descriptors whose loaded words were rewritten #3807
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3807
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3805"
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?
@Leyukaka on GitHub · 2026-12-02 00:51 UTC · original
Leyukaka:py-image-desc→main· +320 −6 · 4 files · 3 commits · merged 2026-12-02 08:56 UTCProblem
s_load_dwordx8reads an eight-word image descriptor from a descriptor table, andtools/startup/gfx2hlsl.pyrecords one symbol per word.Stage.descriptor()names the resource by the first word only, and the image lowerings bind that resource without reading the other words back.A source-built witness shows the defect on
main: afters_mov_b32of a literal into word 1 (format) or word 2 (size) of the loaded descriptor,image_sample_lzandimage_loadthrough that operand were still bound to the unmodified table image. The guest samples an image with another format or size; the translation silently used the original one. Further cases were bound the same way: a word taken from another descriptor, a pointer or descriptor-count value moved into a word, and a word edited in place by scalar ALU.This is part of making the translator base more solid: a form is either translated exactly or refused.
Change
Stage.image_descriptor(), used by the image sample, load, store, gather and comparison lowerings in place ofdescriptor(). It requires every word of the operand that held a loaded descriptor word to still hold the original one: same source, same byte position, same load tag. A descriptor loaded in two halves by twos_load_dwordx4keeps its positions and is still accepted.s_mov_b32, a word of another descriptor, a pointer copy), a word modified in place by scalar ALU, and pointer or descriptor-count data in a word position.set_sand the descriptor ALU path record the SGPRs where a loaded descriptor word was replaced.tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyis widened: for the rewritten-descriptor cases the image access itself is now refused first, with the more preciseimage descriptor s[16:23]: ...message, before the uniformity proof of the read is reached.Validation
Run on Windows (MSVC) with the dev preset:
startup_gfx2hlsl_image_desc_word_witnessis new. Its witnesses (word 1 or word 2 rewritten, a word from another descriptor, pointer and descriptor-count moves, in-place ALU edits, each throughimage_sample_lzandimage_load) failed onmainand pass with this change. The test accepts a refusal or a binding that differs from the unmodified table image.The fixtures are synthetic instruction words and symbols built in the test from the field layouts that
tools/disasm_rdna2.pydecodes; the decoded text of every word is checked first.5c4e141147toeef11ee2c1@Leyukaka on GitHub · 2026-12-02 04:13 UTC · original
Rebased onto
main(0dd65da11) after #3806 merged; both witness registrations are kept inCMakeLists.txt. The gfx2hlsl checks from the description pass again on the new head.@R0Y00 on GitHub · 2026-12-02 05:19 UTC · original · requested changes
The new witness and the existing compute/readfirstlane checks pass. I found one remaining case in the same source-built fixture: insert
s_mov_b32 s16, s2betweenLOADand either image instruction, wheres2is the table pointer. The image instruction is accepted oneef11ee2. Word 0 now holds('ptr', ('table', 0)), words 1–7 still hold the old loaded descriptor, and the emitted resource key becomes(('table', 0), None)throughdescriptor()'s pointer fallback.image_descriptor()returns before consulting the overwrite witness when word 0 is a pointer. Please refuse this mixed operand and add a control for both sample and load, while preserving untouched pointer operands that the translator already accepts.@Leyukaka on GitHub · 2026-12-02 06:12 UTC · original
Thanks. Fixed in
10cd8d847: a pointer in word 0 is refused when any word of the range holds or replaced a loaded descriptor word. Witness covers sample and load and passes on the new head; untouched pointer operands stay accepted. Limit: tracking follows write order, not control flow, so a reused register can be refused.@R0Y00 on GitHub · 2026-12-02 08:55 UTC · original · approved these changes
The previous finding is fixed at
10cd8d84. I ran the descriptor-word witness and five nearby gfx2hlsl checks. Both sample and load now refuse the mixed pointer/descriptor operand, and both still bind an untouched table pointer. Temporarily disabling the new rejection made both mixed-word controls fail, then I restored the exact source.