GPU: hold SHADER_HEAPS across descriptor mirror and check query offsets #52

Manually merged
github merged 1 commit from gh-pr/52/head into gh-pr/52/base 2026-11-26 03:48:20 +00:00
Owner

@⁠AndyLatimer on GitHub · 2026-11-23 23:52 UTC · original
AndyLatimer:fix/gpu-descriptor-mirror-and-query-bounds → main · +83 −15 · 3 files · 1 commits · merged 2026-11-25 00:10 UTC

Fixes a concurrent lifetime bug in descriptor mirroring and three bounds/overflow edge cases in victory-gpu:

  1. descriptor::mirror concurrent Heap::drop UAF (descriptor.rs): shader_slot previously locked SHADER_HEAPS, dereferenced the raw *const Heap into &Heap, and dropped the SHADER_HEAPS lock before returning to mirror. A concurrent Heap::drop on another thread could free the heap before mirror accessed heap.pending / heap.host. mirror now holds the SHADER_HEAPS lock across the access (matching release_dynamic's locking discipline; HostHeap::mirror never locks SHADER_HEAPS).
  2. descriptor::copy_simple and create_heap guards (descriptor.rs): returns early on an unknown descriptor heap kind instead of looping count times calling mirror(dst), and rejects placed heaps whose address + size overflows u64.
  3. list::resolve_queries offset overflow (list.rs): offset + u64::from(count) * bytes > size could overflow u64 (panic in debug builds, wrap in release into an out-of-bounds write). Now uses checked_add with a regression test (resolve_queries_rejects_overflowing_offset).

Testing

  • cargo test -p victory-gpu: 37 passed, 0 failed (including the new resolve_queries_rejects_overflowing_offset test).
  • cargo clippy -p victory-gpu --all-targets: 0 warnings.
  • cargo xtask policy: pass (148 files).
  • Tested with synthetic unit tests only (not run against a title).
**@⁠AndyLatimer** on GitHub · 2026-11-23 23:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/52) `AndyLatimer:fix/gpu-descriptor-mirror-and-query-bounds` → `main` · +83 −15 · 3 files · 1 commits · merged 2026-11-25 00:10 UTC Fixes a concurrent lifetime bug in descriptor mirroring and three bounds/overflow edge cases in `victory-gpu`: 1. **`descriptor::mirror` concurrent `Heap::drop` UAF** (`descriptor.rs`): `shader_slot` previously locked `SHADER_HEAPS`, dereferenced the raw `*const Heap` into `&Heap`, and dropped the `SHADER_HEAPS` lock before returning to `mirror`. A concurrent `Heap::drop` on another thread could free the heap before `mirror` accessed `heap.pending` / `heap.host`. `mirror` now holds the `SHADER_HEAPS` lock across the access (matching `release_dynamic`'s locking discipline; `HostHeap::mirror` never locks `SHADER_HEAPS`). 2. **`descriptor::copy_simple` and `create_heap` guards** (`descriptor.rs`): returns early on an unknown descriptor heap kind instead of looping `count` times calling `mirror(dst)`, and rejects placed heaps whose `address + size` overflows `u64`. 3. **`list::resolve_queries` offset overflow** (`list.rs`): `offset + u64::from(count) * bytes > size` could overflow `u64` (panic in debug builds, wrap in release into an out-of-bounds write). Now uses `checked_add` with a regression test (`resolve_queries_rejects_overflowing_offset`). ## Testing - `cargo test -p victory-gpu`: 37 passed, 0 failed (including the new `resolve_queries_rejects_overflowing_offset` test). - `cargo clippy -p victory-gpu --all-targets`: 0 warnings. - `cargo xtask policy`: pass (148 files). - Tested with synthetic unit tests only (not run against a title).
mirror() previously dropped the SHADER_HEAPS lock inside shader_slot() before using the returned &Heap, allowing a concurrent Heap::drop to free the heap while mirror() accessed it. Also guards copy_simple() against invalid descriptor kinds, rejects placed heaps whose address+size wraps u64, and checks offset+count*bytes in resolve_queries() against overflow (with a regression test).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:48:17 +00:00
github manually merged commit 628b95da5e into gh-pr/52/base 2026-11-26 03:48:20 +00:00
Author
Owner

@⁠lordon1a on GitHub · 2026-11-24 00:19 UTC · original

Verified 628b95da5 on Windows 11 (x86_64-pc-windows-gnullvm, rustc 1.100.0, applied cleanly to main@35b054ec0): pass.

  • cargo xtask policy: 150 files ok
  • cargo test -p victory-gpu: 40 passed, 0 failed (including the new query offset / descriptor heap mirror test + host D3D12 tests).

AI-assisted.

**@⁠lordon1a** on GitHub · 2026-11-24 00:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/52#issuecomment-7117956318) Verified `628b95da5` on Windows 11 (`x86_64-pc-windows-gnullvm`, `rustc 1.100.0`, applied cleanly to `main@35b054ec0`): **pass**. - `cargo xtask policy`: 150 files ok - `cargo test -p victory-gpu`: **40 passed, 0 failed** (including the new query offset / descriptor heap mirror test + host D3D12 tests). AI-assisted.
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:57 UTC · original

Tested 628b95d under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc: pass, no regression.

  • victory_gpu: 35 passed, 2 failed — the PR adds one test, and the two failures are the environment-only ones present on this base (argument_clamp_builds, buffer_data_reaches_the_host_texture, the latter now tracked as #128).
  • Note the branch is based on 97c78d1; the pipeline-library test that fails on vkd3d only exists on newer main, so this run is otherwise clean.

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/52#issuecomment-7118610026) Tested `628b95d` under **Wine 11.22 + vkd3d-proton 3.1** on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo xwin ... --target x86_64-pc-windows-msvc`: **pass, no regression**. - `victory_gpu`: **35 passed, 2 failed** — the PR adds one test, and the two failures are the environment-only ones present on this base (`argument_clamp_builds`, `buffer_data_reaches_the_host_texture`, the latter now tracked as #128). - Note the branch is based on `97c78d1`; the pipeline-library test that fails on vkd3d only exists on newer `main`, so this run is otherwise clean. No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!52
No description provided.