GPU: guard OMSetRenderTargets handle expansion on empty, null, or oversized calls #1428

Open
github-bot wants to merge 1 commit from github-bot/gh-1428 into main AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 17:57 UTC · original
fuzeofficlal:fix/om-set-render-targets-handles-796 → main · +104 −8 · 1 files · 1 commits · open

Fixes #796.

Summary

  • Extract state::target_handles in crates/victory-gpu/src/list.rs so OMSetRenderTargets (state::targets) expands handles into a stack-allocated [u64; D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT] array:
    • Returns early when count == 0 or handles is null so OMSetRenderTargets(0, p, TRUE, &dsv) never dereferences a stale or uninitialized pRenderTargetDescriptors pointer.
    • Clamps count to D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT (8).

Verification

  • list::tests::target_handles_guards_empty_null_and_clamps_to_eight: covers count == 0 with a dangling pointer, null pointer, single-range expansion, array expansion, and clamping to 8.
  • list::tests::om_set_render_targets_zero_count_does_not_read_handles: calls vtable slot 0x190 (OMSetRenderTargets) with count == 0 and a PAGE_NOACCESS pointer (one_range = 1 with &dsv and one_range = 0 with null DSV).
  • cargo clippy -p victory-gpu --tests --locked -- -D warnings and cargo xtask policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-24 17:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1428) `fuzeofficlal:fix/om-set-render-targets-handles-796` → `main` · +104 −8 · 1 files · 1 commits · open Fixes #796. ### Summary - Extract `state::target_handles` in `crates/victory-gpu/src/list.rs` so `OMSetRenderTargets` (`state::targets`) expands handles into a stack-allocated `[u64; D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT]` array: - Returns early when `count == 0` or `handles` is null so `OMSetRenderTargets(0, p, TRUE, &dsv)` never dereferences a stale or uninitialized `pRenderTargetDescriptors` pointer. - Clamps `count` to `D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT` (`8`). ### Verification - `list::tests::target_handles_guards_empty_null_and_clamps_to_eight`: covers `count == 0` with a dangling pointer, null pointer, single-range expansion, array expansion, and clamping to 8. - `list::tests::om_set_render_targets_zero_count_does_not_read_handles`: calls vtable slot `0x190` (`OMSetRenderTargets`) with `count == 0` and a `PAGE_NOACCESS` pointer (`one_range = 1` with `&dsv` and `one_range = 0` with null DSV). - `cargo clippy -p victory-gpu --tests --locked -- -D warnings` and `cargo xtask policy`: passed.
Extract `state::target_handles` in `crates/victory-gpu/src/list.rs` so `OMSetRenderTargets` never dereferences `handles` when `count == 0` or `handles` is null, and clamps `count` to `D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT` (8).

Closes #796.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:31:21 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:27 UTC · original · edited 2026-11-25 11:20 UTC

Automated triage for the maintainers.

Merge candidate.

state::targets in crates/victory-gpu/src/list.rs now goes through state::target_handles. It returns no handles when count == 0 or handles is null, so OMSetRenderTargets(0, p, TRUE, &dsv) no longer reads *p, which is the bug in #796. It also caps count at D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT and uses a stack array in place of a Vec. The array path still goes through items, as before. The tests are short:

  • target_handles assertions for the empty, null, single-range, array and clamp cases.
  • om_set_render_targets_zero_count_does_not_read_handles, which calls vtable slot 0x190 (state::targets, entry 50 of the list vtable) with count == 0 and a PAGE_NOACCESS pointer. That test would fault on main.

CI is passing (check), and the PR merges cleanly.

On your reply: thanks, the head changed to ec57a6e and it does what the last triage asked. The rendering test is gone, the overflow and zero-base guards are dropped, and the crash is covered directly.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1428#issuecomment-7149567045) · edited 2026-11-25 11:20 UTC <!-- victory-triage v1 head=ec57a6e4793c1d78cfa601dcb4489578d6802d73 verdict=merge-candidate at=2026-11-25T11:20:11Z --> Automated triage for the maintainers. **Merge candidate.** `state::targets` in `crates/victory-gpu/src/list.rs` now goes through `state::target_handles`. It returns no handles when `count == 0` or `handles` is null, so `OMSetRenderTargets(0, p, TRUE, &dsv)` no longer reads `*p`, which is the bug in #796. It also caps `count` at `D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT` and uses a stack array in place of a `Vec`. The array path still goes through `items`, as before. The tests are short: - `target_handles` assertions for the empty, null, single-range, array and clamp cases. - `om_set_render_targets_zero_count_does_not_read_handles`, which calls vtable slot `0x190` (`state::targets`, entry 50 of the list vtable) with `count == 0` and a `PAGE_NOACCESS` pointer. That test would fault on `main`. CI is passing (`check`), and the PR merges cleanly. On your reply: thanks, the head changed to `ec57a6e` and it does what the last triage asked. The rendering test is gone, the overflow and zero-base guards are dropped, and the crash is covered directly. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 09:44 UTC · original

Updated in ec57a6e4 per triage feedback:

  • Removed the 540-line D3DCompile/MRT rendering test and replaced the vtable coverage with om_set_render_targets_zero_count_does_not_read_handles, which calls OMSetRenderTargets (0x190) with count == 0 against a PAGE_NOACCESS page (one_range = 1 with &dsv and one_range = 0 with null DSV), alongside the pure target_handles unit checks.
  • Dropped the speculative u64::MAX overflow and zero-base checks, keeping only the count == 0 / null early return and the D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT (8) clamp.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 09:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/1428#issuecomment-7158736974) Updated in `ec57a6e4` per triage feedback: - Removed the 540-line `D3DCompile`/MRT rendering test and replaced the vtable coverage with `om_set_render_targets_zero_count_does_not_read_handles`, which calls `OMSetRenderTargets` (`0x190`) with `count == 0` against a `PAGE_NOACCESS` page (`one_range = 1` with `&dsv` and `one_range = 0` with null DSV), alongside the pure `target_handles` unit checks. - Dropped the speculative `u64::MAX` overflow and zero-base checks, keeping only the `count == 0` / null early return and the `D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT` (`8`) clamp.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1428/head:github-bot/gh-1428'
git switch 'github-bot/gh-1428'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1428'
git switch 'github-bot/gh-1428'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1428'
git switch 'github-bot/gh-1428'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1428'
git switch 'main'
git merge --squash 'github-bot/gh-1428'
git switch 'main'
git merge --ff-only 'github-bot/gh-1428'
git switch 'main'
git merge 'github-bot/gh-1428'
git push origin 'main'
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!1428
No description provided.