Shaders: bound the bytes one part's native blobs unpack to and hand out #1621

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

@⁠imjustprism on GitHub · 2026-11-24 19:52 UTC · original
imjustprism:fix/native-program-size-budget → main · +104 −13 · 1 files · 1 commits · open

a dxil part's xdat index can name the same native blob up to 64 times, and a blob's 8 stage slots can all point at one code range. each blob was only capped at 16 MiB unpacked on its own, so a container of a few KB could make native_programs inflate 1 GiB and copy out about 8 GiB of code before translation even starts. the bytes a part's blobs unpack to and the code and raw table bytes read out of them now come off one 16 MiB budget, and running out is refused as malformed.

real blobs are a few KiB. on a retail dump all 26,148 native programs still read and none hits the new refusal (that run was on an earlier revision of this branch with the same limits). four synthetic tests, each fails without its part of the change. clippy both ways, cargo test --workspace (346 passed) and xtask policy on windows 11.

**@⁠imjustprism** on GitHub · 2026-11-24 19:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1621) `imjustprism:fix/native-program-size-budget` → `main` · +104 −13 · 1 files · 1 commits · open a dxil part's xdat index can name the same native blob up to 64 times, and a blob's 8 stage slots can all point at one code range. each blob was only capped at 16 MiB unpacked on its own, so a container of a few KB could make native_programs inflate 1 GiB and copy out about 8 GiB of code before translation even starts. the bytes a part's blobs unpack to and the code and raw table bytes read out of them now come off one 16 MiB budget, and running out is refused as malformed. real blobs are a few KiB. on a retail dump all 26,148 native programs still read and none hits the new refusal (that run was on an earlier revision of this branch with the same limits). four synthetic tests, each fails without its part of the change. clippy both ways, cargo test --workspace (346 passed) and xtask policy on windows 11.
64 index entries could name one blob and 8 stage slots one code range,
so a small container inflated up to 1 GiB and had about 8 GiB of code
copied out. the bytes a part's blobs unpack to and the code and raw
table bytes read out of them now come off one 16 MiB budget.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:38:39 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:31 UTC · original

Automated triage for the maintainers.

Merge candidate. This replaces the per-blob MAX_UNPACKED cap in native.rs with one 16 MiB PartBudget per part, covering the unpacked sizes and the code and root-table bytes copied out. That closes the case where one XDAT index names the same blob many times, or a blob's stages share one range. The size is checked before inflating, the usize conversion saturates, and the four tests each cover one path. The author reports that every retail program still reads. CI passes.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/1621#issuecomment-7151998073) <!-- victory-triage v1 head=46b2086986d038b91abe5459a7ad1ef1cf5227c9 verdict=merge-candidate at=2026-11-25T03:33:00Z --> Automated triage for the maintainers. **Merge candidate.** This replaces the per-blob `MAX_UNPACKED` cap in `native.rs` with one 16 MiB `PartBudget` per part, covering the unpacked sizes and the code and root-table bytes copied out. That closes the case where one XDAT index names the same blob many times, or a blob's stages share one range. The size is checked before inflating, the `usize` conversion saturates, and the four tests each cover one path. The author reports that every retail program still reads. CI passes. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠StExpeditus on GitHub · 2026-11-25 09:27 UTC · original

Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 46b2086. cargo test --workspace --locked --no-fail-fast -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

**@⁠StExpeditus** on GitHub · 2026-11-25 09:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1621#issuecomment-7158364960) **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `46b2086`. `cargo test --workspace --locked --no-fail-fast` -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 00:55 UTC · original

Code review and Windows 11 verification at head 46b2086986d0 merged cleanly onto main (63bcca43c6a0):

  • Budget & overflow audit (crates/victory-shader/src/native.rs:486-500, 586-648):
    • PartBudget(MAX_PART_BYTES = 16 MiB) debits with checked_sub across the entire part loop (0..count), charging both declared unpacked size (via usize::try_from(...).unwrap_or(usize::MAX) before decompress_to_vec_zlib_with_limit allocates) and extracted code.len() + layout.len() + used.len() (bounded well below overflow since each blob is <= 16 MiB). This prevents both multi-entry zlib inflation and overlapping multi-stage slice amplification from the same blob while returning a clear Malformed error.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy -p victory-shader -p victory-pipeline --all-targets -- -D warnings: 0 warnings
    • victory-shader --lib -- native::: 17/17 passed (including all 4 new budget tests)
    • victory-pipeline --all-targets: 8/8 passed.

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 00:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/1621#issuecomment-7179250143) Code review and Windows 11 verification at head `46b2086986d0` merged cleanly onto `main` (`63bcca43c6a0`): - **Budget & overflow audit (`crates/victory-shader/src/native.rs:486-500, 586-648`)**: - `PartBudget(MAX_PART_BYTES = 16 MiB)` debits with `checked_sub` across the entire part loop (`0..count`), charging both declared `unpacked` size (via `usize::try_from(...).unwrap_or(usize::MAX)` *before* `decompress_to_vec_zlib_with_limit` allocates) and extracted `code.len() + layout.len() + used.len()` (bounded well below overflow since each blob is `<= 16 MiB`). This prevents both multi-entry zlib inflation and overlapping multi-stage slice amplification from the same blob while returning a clear `Malformed` error. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy -p victory-shader -p victory-pipeline --all-targets -- -D warnings`: 0 warnings - `victory-shader --lib -- native::`: **17/17 passed** (including all 4 new budget tests) - `victory-pipeline --all-targets`: **8/8 passed**. LGTM.
github-bot changed title from bound the bytes one part's native blobs unpack to and hand out to Shaders: bound the bytes one part's native blobs unpack to and hand out 2026-11-26 09:03:13 +00:00
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-24 19:56 UTC · original · approved these changes

Verified locally merged onto origin/main (Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib native:: — 14 passed, 0 failed (including the 4 new PartBudget size-budget tests)
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean PartBudget accounting for unpacked native blobs, code, and root tables so oversized blobs are rejected before inflating. Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-24 19:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1621#pullrequestreview-6046365542) · **approved these changes** Verified locally merged onto `origin/main` (Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-shader --lib native::` — 14 passed, 0 failed (including the 4 new `PartBudget` size-budget tests) - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean `PartBudget` accounting for unpacked native blobs, code, and root tables so oversized blobs are rejected before inflating. Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 20:05 UTC · original · approved these changes

Native blob unpacking is now bounded by a PartBudget: code, root tables and unpacked blob bytes all come off one budget, and an oversized blob is refused before it inflates (zip-bomb protection for malformed SGDs). Four new tests cover each budget site and the early refusal. macOS arm64: cargo test -p victory-shader --locked → 100 passed, 0 failed (+4).

**@⁠catminou4** on GitHub · 2026-11-24 20:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1621#pullrequestreview-6046495914) · **approved these changes** Native blob unpacking is now bounded by a `PartBudget`: code, root tables and unpacked blob bytes all come off one budget, and an oversized blob is refused before it inflates (zip-bomb protection for malformed SGDs). Four new tests cover each budget site and the early refusal. macOS arm64: `cargo test -p victory-shader --locked` → **100 passed, 0 failed (+4)**.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 12:26 UTC · original · approved these changes

Reviewed and verified 46b20869 against origin/main (63bcca43; clean git merge-tree):

  • PartBudget(16 << 20) (crates/victory-shader/src/native.rs:143-152, 454, 595-596, 645-647) checks saturated unpacked sizes (usize::try_from(...).unwrap_or(usize::MAX)) with checked_sub before inflating and charges code.len() + layout.len() + used.len() before copying/collecting, preventing repeated XDAT entries and shared stage ranges from amplifying allocations.

Non-blocking boundary note: because decompression (S) and emitted code/table bytes (P) now share one 16 MiB budget, a single valid code-heavy blob just above ~8 MiB (S + P > 16 MiB) that previously passed MAX_UNPACKED = 16 MiB will now be refused. Documenting that single-blob boundary (or adding exact 16 MiB / 16 MiB + 1 B boundary tests) would lock the contract down cleanly.

Local verification on 46b20869: rustfmt --edition 2024 --check crates/victory-shader/src/native.rs, xtask policy (182 files ok), cargo clippy -p victory-shader --all-targets -- -D warnings (default & --all-features), and cargo test -p victory-shader --lib native:: (17 passed; 0 failed) all pass.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 12:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1621#pullrequestreview-6074097740) · **approved these changes** Reviewed and verified `46b20869` against `origin/main` (`63bcca43`; clean `git merge-tree`): - `PartBudget(16 << 20)` (`crates/victory-shader/src/native.rs:143-152, 454, 595-596, 645-647`) checks saturated `unpacked` sizes (`usize::try_from(...).unwrap_or(usize::MAX)`) with `checked_sub` before inflating and charges `code.len() + layout.len() + used.len()` before copying/collecting, preventing repeated XDAT entries and shared stage ranges from amplifying allocations. Non-blocking boundary note: because decompression (`S`) and emitted code/table bytes (`P`) now share one 16 MiB budget, a single valid code-heavy blob just above ~8 MiB (`S + P > 16 MiB`) that previously passed `MAX_UNPACKED = 16 MiB` will now be refused. Documenting that single-blob boundary (or adding exact `16 MiB` / `16 MiB + 1 B` boundary tests) would lock the contract down cleanly. Local verification on `46b20869`: `rustfmt --edition 2024 --check crates/victory-shader/src/native.rs`, `xtask policy` (`182 files ok`), `cargo clippy -p victory-shader --all-targets -- -D warnings` (default & `--all-features`), and `cargo test -p victory-shader --lib native::` (`17 passed; 0 failed`) all pass.
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/1621/head:github-bot/gh-1621'
git switch 'github-bot/gh-1621'

Merge

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