GPU: a plain heap description is not read past its 16 bytes without checking they are mapped #2278

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

@⁠denkencar-sketch on GitHub · 2026-11-25 09:29 UTC · original
denkencar-sketch:fix/desc-001 → main · +50 −3 · 1 files · 1 commits · open

Summary

A plain heap description was read past its 16 bytes without checking they are mapped, so an older title's description at the end of its memory faulted. The placement of a newer title's extended description is now read through the kernel.

Testing

Test a_plain_description_at_the_end_of_mapped_memory_is_read_whole crashes (0xc0000005) on main and passes with this change. cargo test --workspace --locked passes apart from the known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not tried: the non-Windows path (unchanged), and a run in the game.

AI-assisted.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 09:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2278) `denkencar-sketch:fix/desc-001` → `main` · +50 −3 · 1 files · 1 commits · open ## Summary A plain heap description was read past its 16 bytes without checking they are mapped, so an older title's description at the end of its memory faulted. The placement of a newer title's extended description is now read through the kernel. ## Testing Test `a_plain_description_at_the_end_of_mapped_memory_is_read_whole` crashes (`0xc0000005`) on `main` and passes with this change. `cargo test --workspace --locked` passes apart from the known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not tried: the non-Windows path (unchanged), and a run in the game. AI-assisted.
The placement of a newer title's extended description is read through the
kernel, so an older title's description at the end of its memory does not
fault.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:00:46 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-25 09:37 UTC · original

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

**@⁠DesertGamer** on GitHub · 2026-11-25 09:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2278#issuecomment-7158583864) ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:32 UTC · original · edited 2026-11-26 01:25 UTC

Automated triage for the maintainers.

Merge candidate. Rebased onto current main, one commit, merges cleanly.

In crates/victory-gpu/src/descriptor.rs, create_heap used to read the 16 bytes after a plain heap description directly, as a possible extended placement. It now reads them through placement_after, which on Windows uses crate::host::read_into (ReadProcessMemory on the current process, already used elsewhere in the crate) and returns a zero placement when those bytes are not readable. A zero placement is not mistaken for an extended one, because recognition requires its size to match the count. a_plain_description_at_the_end_of_mapped_memory_is_read_whole puts the description at the end of a page followed by a PAGE_NOACCESS page, and checks that the heap is created instead of faulting. Nit: the non-Windows branch's SAFETY: as above no longer has a safety comment above it to refer to.

CI: passing (check). Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2278#issuecomment-7163916021) · edited 2026-11-26 01:25 UTC <!-- victory-triage v1 head=0d92d58a02c0aa1dd6b57cb1f955bc2addbb6ac6 verdict=merge-candidate at=2026-11-26T01:25:15Z --> Automated triage for the maintainers. **Merge candidate.** Rebased onto current `main`, one commit, merges cleanly. In `crates/victory-gpu/src/descriptor.rs`, `create_heap` used to read the 16 bytes after a plain heap description directly, as a possible extended placement. It now reads them through `placement_after`, which on Windows uses `crate::host::read_into` (`ReadProcessMemory` on the current process, already used elsewhere in the crate) and returns a zero placement when those bytes are not readable. A zero placement is not mistaken for an extended one, because recognition requires its size to match the count. `a_plain_description_at_the_end_of_mapped_memory_is_read_whole` puts the description at the end of a page followed by a `PAGE_NOACCESS` page, and checks that the heap is created instead of faulting. Nit: the non-Windows branch's `SAFETY: as above` no longer has a safety comment above it to refer to. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 09:35 UTC · original · reviewed

A plain heap description is not read past its 16 bytes: placement_after() probes with read_into on Windows instead of a blind unaligned read. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Defensive fix for titles passing stack/data as HeapDesc; the non-Windows fallback still does the blind read (noted, Windows-only crate anyway).

**@⁠catminou4** on GitHub · 2026-11-25 09:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2278#pullrequestreview-6055075875) · **reviewed** A plain heap description is not read past its 16 bytes: placement_after() probes with read_into on Windows instead of a blind unaligned read. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Defensive fix for titles passing stack/data as HeapDesc; the non-Windows fallback still does the blind read (noted, Windows-only crate anyway).
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 09:42 UTC · original · approved these changes

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib descriptor::tests:: — 6 passed, 0 failed (including a_plain_description_at_the_end_of_mapped_memory_is_read_whole)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean mapped-memory guard preventing out-of-bounds reads past 16-byte plain HeapDesc structs. Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 09:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2278#pullrequestreview-6055168200) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib descriptor::tests::` — **6 passed, 0 failed** (including `a_plain_description_at_the_end_of_mapped_memory_is_read_whole`) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean mapped-memory guard preventing out-of-bounds reads past 16-byte plain `HeapDesc` structs. Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

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

Reviewed 0d92d58a02c0aa1dd6b57cb1f955bc2addbb6ac6 (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer.

Audit

  • crates/victory-gpu/src/descriptor.rs:740, :744, :772: placement_after probes the 16 bytes following HeapDesc through crate::host::read_into(desc_ptr.wrapping_add(1).cast(), &mut bytes) on Windows and falls back to a zero Placement when unreadable, preventing access violations when a plain 16-byte HeapDesc ends at or near a PAGE_NOACCESS boundary while decoding valid 32-byte extended HeapDesc + Placement records identically. Non-Windows fallback compiles cleanly under #[cfg(not(windows))].

Verification

  • Clean merge onto 63bcca43c6a00a758510398fa43096ce7e4f7df0 + cargo run -p xtask -- policy (191 files ok)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default & --all-features)
  • victory-gpu with VICTORY_D3D12_DEBUG=1: descriptor::tests:: 8/8 passed on RTX 5090; full descriptor:: 23/23 passed (--features diagnostics) on WARP (including a_plain_description_at_the_end_of_mapped_memory_is_read_whole).
  • Also ran a custom probe on both RTX 5090 and WARP verifying (1) a plain HeapDesc placed at page + 4096 - 24 (with only 8 mapped bytes of non-zero data before PAGE_NOACCESS) falls back cleanly without faulting or trusting partial bytes, and (2) a mapped 32-byte extended HeapDesc + Placement is still recognized and honors placement.address.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 15:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2278#pullrequestreview-6077100954) · **approved these changes** Reviewed `0d92d58a02c0aa1dd6b57cb1f955bc2addbb6ac6` (merged cleanly onto `63bcca43c6a00a758510398fa43096ce7e4f7df0`) and verified on Windows 11 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer. ### Audit - `crates/victory-gpu/src/descriptor.rs:740`, `:744`, `:772`: `placement_after` probes the 16 bytes following `HeapDesc` through `crate::host::read_into(desc_ptr.wrapping_add(1).cast(), &mut bytes)` on Windows and falls back to a zero `Placement` when unreadable, preventing access violations when a plain 16-byte `HeapDesc` ends at or near a `PAGE_NOACCESS` boundary while decoding valid 32-byte extended `HeapDesc + Placement` records identically. Non-Windows fallback compiles cleanly under `#[cfg(not(windows))]`. ### Verification - Clean merge onto `63bcca43c6a00a758510398fa43096ce7e4f7df0` + `cargo run -p xtask -- policy` (`191 files ok`) - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default & `--all-features`) - `victory-gpu` with `VICTORY_D3D12_DEBUG=1`: `descriptor::tests::` **8/8 passed** on RTX 5090; full `descriptor::` **23/23 passed** (`--features diagnostics`) on WARP (including `a_plain_description_at_the_end_of_mapped_memory_is_read_whole`). - Also ran a custom probe on both RTX 5090 and WARP verifying (1) a plain `HeapDesc` placed at `page + 4096 - 24` (with only 8 mapped bytes of non-zero data before `PAGE_NOACCESS`) falls back cleanly without faulting or trusting partial bytes, and (2) a mapped 32-byte extended `HeapDesc + Placement` is still recognized and honors `placement.address`.
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/2278/head:github-bot/gh-2278'
git switch 'github-bot/gh-2278'

Merge

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