Recompiler: guard 32-bit raw-buffer OOB wraparound in Direct DXIL #3265

Merged
Foniass merged 1 commit from upstream-pr/3265 into main 2026-11-29 13:58:40 +00:00
Foniass commented 2026-11-29 02:18:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T02:18:32Z.


Overlaps #1933 (PracticalStudios, same issue #1893, mergeable): this is amd-dev's version (fcbd0d14, raylitebull). Maintainers, keep one of the two.

In direct DXIL, raw buffer_load / buffer_atomic (stride 0) computed off = voff + OFFSET and e = off + bytes and compared them with the buffer size without checking 32-bit wraparound (#1893). A voff near 2^32 wrapped below the size, passed the bounds check, and the 64-bit window address carried into the next 4 GiB window. The check now also requires off >= voff (when OFFSET != 0) and e >= off, in 32-bit arithmetic.

What is in it

  • crates/xcl/src/gpu/dxil/lower_mem.rs: the carry checks
  • crates/xcl/src/gpu/dxil/core_tests.rs: raw_buffer_oob_check_guards_32bit_wraparound

Tested

  • RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on cb7fe9bd: 2605 passed, 4 failed, 49 ignored. The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3: E_OUTOFMEMORY from CreateComputePipelineState at seeds 70 / 545 / 1019 / 1507, the same as on main on this machine; they pass on Kalmarv's RTX 5070 Ti, so they come from this machine's driver / setup, not the code. SKIPPED GPU tests: 30, almost all no wave64.
  • Correction: in the first push the test's load and atomic used the same offset, so main's CSE shared their checks and the test failed (found by Kalmarv). The atomic now uses OFFSET 20, as in amd-dev's later f089a9df.
  • The test sits at the end of core_tests.rs (head cb7fe9bd): in the first pushes it was at the same line as #3266's test, a merge conflict Kalmarv found; nothing else changed.
  • Retail title: 60 s smoke run below. The PR's run used -StartupTimeoutSeconds 3600 for the cold pipeline rebuild new DXIL needs.

Regression run

main:

xcl-smoke v1
commit: b10cc4c6766adc947c2054ada4a2af98be15108d
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16026 MB

this PR:

xcl-smoke v1
commit: cb7fe9bd79ca8d2b55c229190a0dc8572749a1e9
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1649 (PresentX 1649)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16072 MB

Not tested

  • AMD GPUs; whether the image looks the same; titles other than this one

AI use

  • Claude Code with Claude Opus 5.5: ported the commit to main, resolved conflicts (noted in the commit message), ran the tests and the smoke run above and wrote this description.
  • Original commit: amd-dev fcbd0d14 (raylitebull, from 70e600d5, written with Antigravity (Gemini 4 Neon High)).

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5546753627 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3265). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T02:18:32Z. --- **Overlaps #1933** (PracticalStudios, same issue #1893, mergeable): this is amd-dev's version (`fcbd0d14`, raylitebull). Maintainers, keep one of the two. In direct DXIL, raw `buffer_load` / `buffer_atomic` (stride 0) computed `off = voff + OFFSET` and `e = off + bytes` and compared them with the buffer size without checking 32-bit wraparound (#1893). A `voff` near 2^32 wrapped below the size, passed the bounds check, and the 64-bit window address carried into the next 4 GiB window. The check now also requires `off >= voff` (when OFFSET != 0) and `e >= off`, in 32-bit arithmetic. **What is in it** - `crates/xcl/src/gpu/dxil/lower_mem.rs`: the carry checks - `crates/xcl/src/gpu/dxil/core_tests.rs`: `raw_buffer_oob_check_guards_32bit_wraparound` **Tested** - RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke - `cargo test --workspace --no-fail-fast -- --test-threads=4` on cb7fe9bd: 2605 passed, 4 failed, 49 ignored. The 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3`: `E_OUTOFMEMORY` from `CreateComputePipelineState` at seeds 70 / 545 / 1019 / 1507, the same as on main on this machine; they pass on Kalmarv's RTX 5070 Ti, so they come from this machine's driver / setup, not the code. SKIPPED GPU tests: 30, almost all `no wave64`. - Correction: in the first push the test's load and atomic used the same offset, so main's CSE shared their checks and the test failed (found by Kalmarv). The atomic now uses `OFFSET` 20, as in amd-dev's later `f089a9df`. - The test sits at the end of `core_tests.rs` (head `cb7fe9bd`): in the first pushes it was at the same line as #3266's test, a merge conflict Kalmarv found; nothing else changed. - Retail title: 60 s smoke run below. The PR's run used `-StartupTimeoutSeconds 3600` for the cold pipeline rebuild new DXIL needs. **Regression run** main: ``` xcl-smoke v1 commit: b10cc4c6766adc947c2054ada4a2af98be15108d gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1565 (PresentX 1565) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16026 MB ``` this PR: ``` xcl-smoke v1 commit: cb7fe9bd79ca8d2b55c229190a0dc8572749a1e9 gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1649 (PresentX 1649) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16072 MB ``` **Not tested** - AMD GPUs; whether the image looks the same; titles other than this one **AI use** - Claude Code with Claude Opus 5.5: ported the commit to main, resolved conflicts (noted in the commit message), ran the tests and the smoke run above and wrote this description. - Original commit: amd-dev `fcbd0d14` (raylitebull, from `70e600d5`, written with Antigravity (Gemini 4 Neon High)). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kalmarv commented 2026-11-29 03:23:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:23:06Z.


merge-check
base: fa204595a4
head: cb7fe9bd79
merge: clean onto main and with the 7-PR stack (zero conflicts after test move).
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok.
tests: tested in the clean 7-PR stack (#3250+#3261+#3263+#3264+#3265+#3266+#3268) on main fa204595: cargo test --workspace --no-fail-fast -- --test-threads=4 (DXC 1.9.2609.5; -p xcl --lib rerun skipping the 2 known main #3187 uma_driver mixed-window tests a_refused_gpu_upload_segment_becomes_custom and mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment) -> 2620 passed, 0 failed, 49 ignored (2481 lib + 139 integration, 25 SKIPPED notices; all 4 fuzz_validate_and_gpu_0..3 passed); failing: none. raw_buffer_oob_check_guards_32bit_wraparound ran and passed. 150 s xcl-smoke (ea3b5e4d, XCL_PREPARE=0, RTX 5070 Ti) on the combined 8-PR stack: exit: 0x0, 2096 frames shown, 0 device removals, 0 crashes, 0 display System events, 32049 MB peak commit.
review: none (whole diff read: pure 32-bit unsigned carry checks off >= voff when OFFSET != 0 and e >= off before e <= d2 in lower_mem.rs, closing 32-bit OOB wraparound without i64 promotion).
performance: negligible: two scalar icmp uge ops on raw buffer OOB checks; no regression in 150 s smoke.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (wave32 only), Windows 11, DXC 1.9.2609.5 via XCL_DXC_DIR; Antigravity (Gemini 3.5 Pro) ran the merges, builds, workspace test suites, 150 s title smokes, diff reviews, and drafted this check.

<!-- greyfinch-sync:ivall/xcl:comment:7250015029 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3265#issuecomment-7250015029). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T03:23:06Z. --- merge-check base: fa204595a488c60c6c5f905244f0172072c9c2a9 head: cb7fe9bd79ca8d2b55c229190a0dc8572749a1e9 merge: clean onto main and with the 7-PR stack (zero conflicts after test move). build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok. tests: tested in the clean 7-PR stack (#3250+#3261+#3263+#3264+#3265+#3266+#3268) on main `fa204595`: `cargo test --workspace --no-fail-fast -- --test-threads=4` (DXC 1.9.2609.5; `-p xcl --lib` rerun skipping the 2 known `main` #3187 `uma_driver` mixed-window tests `a_refused_gpu_upload_segment_becomes_custom` and `mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment`) -> 2620 passed, 0 failed, 49 ignored (2481 lib + 139 integration, 25 SKIPPED notices; all 4 `fuzz_validate_and_gpu_0..3` passed); failing: none. `raw_buffer_oob_check_guards_32bit_wraparound` ran and passed. 150 s `xcl-smoke` (`ea3b5e4d`, `XCL_PREPARE=0`, RTX 5070 Ti) on the combined 8-PR stack: `exit: 0x0`, `2096` frames shown, `0` device removals, `0` crashes, `0` display System events, `32049 MB` peak commit. review: none (whole diff read: pure 32-bit unsigned carry checks `off >= voff` when `OFFSET != 0` and `e >= off` before `e <= d2` in `lower_mem.rs`, closing 32-bit OOB wraparound without i64 promotion). performance: negligible: two scalar `icmp uge` ops on raw buffer OOB checks; no regression in 150 s smoke. verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (wave32 only), Windows 11, DXC 1.9.2609.5 via XCL_DXC_DIR; Antigravity (Gemini 3.5 Pro) ran the merges, builds, workspace test suites, 150 s title smokes, diff reviews, and drafted this check.
throny commented 2026-11-29 09:01:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-29T09:01:29Z.


merge-check claim
head: cb7fe9bd79

<!-- greyfinch-sync:ivall/xcl:comment:7253484451 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3265#issuecomment-7253484451). Originally posted by [throny](https://github.com/throny) on 2026-11-29T09:01:29Z. --- merge-check claim head: cb7fe9bd79ca8d2b55c229190a0dc8572749a1e9
throny commented 2026-11-29 09:20:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-29T09:20:37Z.


merge-check
base: d8bd9a38
head: cb7fe9bd79
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2619 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at d8bd9a38: 2618 passed, 0 failed, 49 ignored.
review: no blocking finding. An offset sum that wraps 32 bits is now treated as out of range for buffer loads, stores and atomics in direct DXIL, which matches the HLSL path's 64-bit check when there is more than one memory window. With a single window the HLSL path still wraps in 32 bits, so the two translators differ there after this change. The test is weak: it counts a comparison pattern in the whole module and returns silently when disassembly fails. This is the same work as the older open #1933 (listed on #1607); one of the two should be closed.
performance: not measured (one more comparison per access).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7253699029 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3265#issuecomment-7253699029). Originally posted by [throny](https://github.com/throny) on 2026-11-29T09:20:37Z. --- merge-check base: d8bd9a38 head: cb7fe9bd79ca8d2b55c229190a0dc8572749a1e9 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2619 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at d8bd9a38: 2618 passed, 0 failed, 49 ignored. review: no blocking finding. An offset sum that wraps 32 bits is now treated as out of range for buffer loads, stores and atomics in direct DXIL, which matches the HLSL path's 64-bit check when there is more than one memory window. With a single window the HLSL path still wraps in 32 bits, so the two translators differ there after this change. The test is weak: it counts a comparison pattern in the whole module and returns silently when disassembly fails. This is the same work as the older open #1933 (listed on #1607); one of the two should be closed. performance: not measured (one more comparison per access). verdict: safe to merge hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
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
xcl-dev/xcl!3265
No description provided.