GPU: initialize title-memory page tables to null entries and guard range overflow #2544

Closed
github-bot wants to merge 1 commit from gh-pr/2544/head into gh-pr/2544/base
Owner

@⁠reeledMarek on GitHub · 2026-11-25 15:33 UTC · original
reeledMarek:fix/gpu-memory-table-init-and-overflow → main · +28 −3 · 1 files · 1 commits · closed without merging

Problem

  1. memory::Shared::new() allocated the upload buffer for a heap's title-memory page table without initializing level 1 and block 0 to [self.null, 0]. If a title bound title memory on a new heap and released the heap before submitting the list, memory::prepare could not run rewrite(), leaving shaders reading an all-zero page table that pointed to descriptor heap slot 0 instead of self.null.
  2. memory::table() checked start + len > 1 << 40 with unchecked addition, which panics in debug or wraps in release for overflowing ranges.

Fix

  • Populate level 1 and block 0 of newly created page tables with table(&[], &[], null) in Shared::new().
  • Use start.checked_add(len) in memory::table().

Testing

  • Added overflowing_copy_ranges_are_ignored_and_empty_table_routes_to_null in crates/victory-gpu/src/memory.rs.
  • Verified cargo test -p xtask --locked passes asset policy.
**@⁠reeledMarek** on GitHub · 2026-11-25 15:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2544) `reeledMarek:fix/gpu-memory-table-init-and-overflow` → `main` · +28 −3 · 1 files · 1 commits · closed without merging ### Problem 1. `memory::Shared::new()` allocated the upload buffer for a heap's title-memory page table without initializing level 1 and block 0 to `[self.null, 0]`. If a title bound title memory on a new heap and released the heap before submitting the list, `memory::prepare` could not run `rewrite()`, leaving shaders reading an all-zero page table that pointed to descriptor heap slot `0` instead of `self.null`. 2. `memory::table()` checked `start + len > 1 << 40` with unchecked addition, which panics in debug or wraps in release for overflowing ranges. ### Fix - Populate level 1 and block 0 of newly created page tables with `table(&[], &[], null)` in `Shared::new()`. - Use `start.checked_add(len)` in `memory::table()`. ### Testing - Added `overflowing_copy_ranges_are_ignored_and_empty_table_routes_to_null` in `crates/victory-gpu/src/memory.rs`. - Verified `cargo test -p xtask --locked` passes asset policy.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:08:47 +00:00
github-bot closed this pull request 2026-11-26 05:08:47 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 18:35 UTC · original

Automated triage for the maintainers.

Two changes in victory-gpu/src/memory.rs:

  1. table() uses checked_add. The ranges come only from Shadow::range() of registered host copies (Shared::rewrite), so start + len cannot overflow a u64. This guards a case that can't happen, and the test only exercises it with made-up ranges. Please drop it unless you can show a caller that passes such a range.
  2. Shared::new fills the page table with null entries. bind creates the table, and every submission that uses it runs prepare, which rewrites it (generation starts at u64::MAX). So the zeroed table is only ever read if the title's heap has already been released when the list is submitted. That is invalid use of the heap anyway, and the null pair lives in that same heap. The fill is cheap and harmless, but it needs a concrete case where it changes behaviour: a log or a sequence of title calls showing a list submitted after its heap was released.

With (1) removed and (2) motivated, this could go in as a small hardening change. CI checks: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 18:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2544#issuecomment-7171112296) <!-- victory-triage v1 head=ae0d9f674459c4b33888db25310b042ab07eba35 verdict=needs-work at=2026-11-25T18:35:00Z --> Automated triage for the maintainers. Two changes in `victory-gpu/src/memory.rs`: 1. **`table()` uses `checked_add`.** The ranges come only from `Shadow::range()` of registered host copies (`Shared::rewrite`), so `start + len` cannot overflow a `u64`. This guards a case that can't happen, and the test only exercises it with made-up ranges. Please drop it unless you can show a caller that passes such a range. 2. **`Shared::new` fills the page table with null entries.** `bind` creates the table, and every submission that uses it runs `prepare`, which rewrites it (`generation` starts at `u64::MAX`). So the zeroed table is only ever read if the title's heap has already been released when the list is submitted. That is invalid use of the heap anyway, and the null pair lives in that same heap. The fill is cheap and harmless, but it needs a concrete case where it changes behaviour: a log or a sequence of title calls showing a list submitted after its heap was released. With (1) removed and (2) motivated, this could go in as a small hardening change. CI checks: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-25 20:05 UTC · original

Closing per triage — Shadow::range() cannot overflow and prepare() always populates the page table before valid use. Thanks for the review!

**@⁠reeledMarek** on GitHub · 2026-11-25 20:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2544#issuecomment-7173181528) Closing per triage — `Shadow::range()` cannot overflow and `prepare()` always populates the page table before valid use. Thanks for the review!

Pull request closed

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!2544
No description provided.