victory-shader: malformed signature or native data can abort the process or overflow (capacity, mask, user SGPR, thread-group size) #222

Open
opened 2026-11-26 12:04:47 +00:00 by github-bot · 0 comments
Owner

@⁠kekonn on GitHub · 2026-11-26 11:59 UTC · original

Four small guards on the runtime translation path. Each needs a malformed container: real console shaders don't hit these. Two of them can still kill the process or panic in a debug build.

  • Capacity from an unchecked count. crates/victory-shader/src/emit/mod.rs:900 Vec::with_capacity(count), with count the first dword of ISG1/OSG1/PSG1. A count of 0xFFFFFFFF asks for about 206 GB; the allocation fails and Rust aborts the process, which catch_unwind cannot catch. Fix: count.min(part.len() / 32), following shader_cache::decode's n.min(…).
  • Signature mask wider than 4 bits. emit/mod.rs:908 reads the mask byte as is. 0xFF gives cols = 8, and (1u8 << 8) - 1 at container.rs:63 (also rect.rs:88/114, host.rs:708) panics in debug and gives mask 0 in release. Fix: & 0xF (or return Malformed) where the byte is read.
  • User SGPR overflow. crates/victory-shader/src/native.rs:161 does index + 8 on a raw u8 from the root table. Values of 248 and up panic in debug and wrap in release, so the wrong root parameter gets matched (resource.rs param_of ~579). Fix: index.saturating_add(8), and checked_add(1) at resource.rs ~975.
  • Unbounded thread-group size. FSSM (native.rs ~729-735) and FSPX (~571) copy thread counts unchecked. product::<u32>() (lower.rs ~1842) and x * y (~5135, ~5167) then overflow. Fix: a group() check in native.rs that returns Malformed when a dimension or the product is above 1024 (zeros stay accepted; a fixture uses [0,0,0]).

Upstream: none of the open PRs fix these. #81, #18 and #109 add more unchecked thread products in lower.rs, which a check in native.rs covers too.
Status: a fix is being prepared in kekonn/VIctory-7900XTX on branch claude/gifted-clarke-uxuqw8.


Generated by Claude Code

**@⁠kekonn** on GitHub · 2026-11-26 11:59 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/222) Four small guards on the runtime translation path. Each needs a malformed container: real console shaders don't hit these. Two of them can still kill the process or panic in a debug build. - [ ] **Capacity from an unchecked count.** `crates/victory-shader/src/emit/mod.rs:900` `Vec::with_capacity(count)`, with `count` the first dword of ISG1/OSG1/PSG1. A count of `0xFFFFFFFF` asks for about 206 GB; the allocation fails and Rust **aborts the process**, which `catch_unwind` cannot catch. Fix: `count.min(part.len() / 32)`, following `shader_cache::decode`'s `n.min(…)`. - [ ] **Signature mask wider than 4 bits.** `emit/mod.rs:908` reads the mask byte as is. `0xFF` gives `cols = 8`, and `(1u8 << 8) - 1` at `container.rs:63` (also `rect.rs:88/114`, `host.rs:708`) panics in debug and gives mask 0 in release. Fix: `& 0xF` (or return `Malformed`) where the byte is read. - [ ] **User SGPR overflow.** `crates/victory-shader/src/native.rs:161` does `index + 8` on a raw `u8` from the root table. Values of 248 and up panic in debug and wrap in release, so the wrong root parameter gets matched (`resource.rs` `param_of` ~579). Fix: `index.saturating_add(8)`, and `checked_add(1)` at `resource.rs` ~975. - [ ] **Unbounded thread-group size.** FSSM (`native.rs` ~729-735) and FSPX (~571) copy thread counts unchecked. `product::<u32>()` (`lower.rs` ~1842) and `x * y` (~5135, ~5167) then overflow. Fix: a `group()` check in `native.rs` that returns `Malformed` when a dimension or the product is above 1024 (zeros stay accepted; a fixture uses `[0,0,0]`). **Upstream:** none of the open PRs fix these. #81, #18 and #109 add more unchecked thread products in `lower.rs`, which a check in `native.rs` covers too. **Status:** a fix is being prepared in kekonn/VIctory-7900XTX on branch `claude/gifted-clarke-uxuqw8`. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:04:47 +00:00
This discussion has been locked. Commenting is limited to contributors.
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/avatarmanz--VIctory-7900XTX#222
No description provided.