shader: reject raw indexed reads without a proven source stride #2225

Merged
chadhyatt merged 1 commit from upstream-pr/2233 into main 2026-11-25 07:06:57 +00:00
chadhyatt commented 2026-11-25 06:43:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chadhyatt on 2026-11-25T06:43:36Z.


Refs #2022 and #2174. A formatted heap-view load obtains and validates a dynamic stride. A subsequent raw indexed read must not borrow it: the generic address builder can emit tid.x * Noneu, because the heap profile excludes a static source stride. Keep the formatted heap helper path and ordinary static-stride raw path distinct.

Source-built controls check formatted success, mixed formatted/raw rejection, and static-stride raw success. On base 06913dc1, python3 -B -c 'import sys; sys.path.insert(0,"tests"); import compute_store_check as t; t.read_controls()' fails with Expected rejection: Unsupported read address; on d04a5c4f it passes. python3 -B tests/compute_load_format_check.py controls, python3 -B tests/compute_heap_view_check.py controls, python3 -B tests/compute_heap_store_check.py controls, and python3 -B tests/compute_store_check.py binary /opt/homebrew/opt/llvm@21/bin/llvm-mc /opt/homebrew/opt/llvm@21/bin/llvm-objcopy /opt/homebrew/opt/llvm@21/lib/libLLVM.dylib all passed on Apple Silicon macOS. Windows GPU readback not run locally; no new hardware or coverage claim.

AI-assisted backport patch from x2w-microlift.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6598864146 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2233). Originally posted by [chadhyatt](https://github.com/chadhyatt) on 2026-11-25T06:43:36Z. --- Refs #2022 and #2174. A formatted heap-view load obtains and validates a dynamic stride. A subsequent raw indexed read must not borrow it: the generic address builder can emit `tid.x * Noneu`, because the heap profile excludes a static source stride. Keep the formatted heap helper path and ordinary static-stride raw path distinct. Source-built controls check formatted success, mixed formatted/raw rejection, and static-stride raw success. On base 06913dc1, `python3 -B -c 'import sys; sys.path.insert(0,"tests"); import compute_store_check as t; t.read_controls()'` fails with `Expected rejection: Unsupported read address`; on d04a5c4f it passes. `python3 -B tests/compute_load_format_check.py controls`, `python3 -B tests/compute_heap_view_check.py controls`, `python3 -B tests/compute_heap_store_check.py controls`, and `python3 -B tests/compute_store_check.py binary /opt/homebrew/opt/llvm@21/bin/llvm-mc /opt/homebrew/opt/llvm@21/bin/llvm-objcopy /opt/homebrew/opt/llvm@21/lib/libLLVM.dylib` all passed on Apple Silicon macOS. Windows GPU readback not run locally; no new hardware or coverage claim. AI-assisted backport patch from x2w-microlift.
tedin7 commented 2026-11-25 07:01:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:46:44Z.

Review: COMMENTED


Review of head d04a5c4f7c (python-only: tools/compute_store_aot.py, tests/compute_store_check.py, docs/experiments.md).

Findings: 0 P1, 0 P2.

Logic: a raw (non-formatted) idxen read with a heap view no longer skips the element-bounds check. Only the formatted heap-view helper (load_heap_view_format) obtains a runtime stride and bounds the read, so it keeps the dedicated branch. Raw reads fall to the static source_stride branch and are rejected with "Unsupported read address" when no static stride is proven. The accepted formatted path is unchanged. The new test covers: formatted heap-view load accepted, raw read after it rejected, and raw read with a static stride accepted.

Commands executed locally:

  • python3 tests/compute_store_check.py (module-level controls pass up to the argv parse; the draw modes need DXC and run on Windows CI)
  • python3 tests/docs_links_check.py: PASS (417 links)
  • python3 tests/bidi_controls_check.py: PASS
  • git diff --check origin/main...HEAD: clean
  • Mutation 1: widen the heap-view branch to any read (drop and descriptor_load is not None): new test fails ("Expected rejection: Unsupported read address").
  • Mutation 2: disable the offset + read_bytes > source_stride check: test fails ("Expected rejection: Read leaves its source element").
  • Worktree restored with git checkout -- . after each mutation.

No concurrent open PR covers this check. Windows CI job is still pending at review time.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053044109 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2233#pullrequestreview-6053044109). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T06:46:44Z. **Review:** COMMENTED --- Review of head d04a5c4f7cbbe5b8e5982507033689526b09c38d (python-only: tools/compute_store_aot.py, tests/compute_store_check.py, docs/experiments.md). Findings: 0 P1, 0 P2. Logic: a raw (non-formatted) idxen read with a heap view no longer skips the element-bounds check. Only the formatted heap-view helper (`load_heap_view_format`) obtains a runtime stride and bounds the read, so it keeps the dedicated branch. Raw reads fall to the static `source_stride` branch and are rejected with "Unsupported read address" when no static stride is proven. The accepted formatted path is unchanged. The new test covers: formatted heap-view load accepted, raw read after it rejected, and raw read with a static stride accepted. Commands executed locally: - `python3 tests/compute_store_check.py` (module-level controls pass up to the argv parse; the draw modes need DXC and run on Windows CI) - `python3 tests/docs_links_check.py`: PASS (417 links) - `python3 tests/bidi_controls_check.py`: PASS - `git diff --check origin/main...HEAD`: clean - Mutation 1: widen the heap-view branch to any read (drop `and descriptor_load is not None`): new test fails ("Expected rejection: Unsupported read address"). - Mutation 2: disable the `offset + read_bytes > source_stride` check: test fails ("Expected rejection: Read leaves its source element"). - Worktree restored with `git checkout -- .` after each mutation. No concurrent open PR covers this check. Windows CI job is still pending at review time. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 08:04:53 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2225
No description provided.