startup: check the logical view table bounds #1443

Merged
Asimmimx merged 1 commit from upstream-pr/1450 into main 2026-11-24 11:57:30 +00:00
Asimmimx commented 2026-11-24 11:45:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T11:45:43Z.


Change

Refs #1149. This adds a device-free check for src/startup_stubs/logical_view_table.h. The header decides which part of the title's descriptor memory a translated draw may read through a root table handle. list_table (list slot 36) calls resolve_view_table, and the SRV gather calls ViewTable::record, both in d3d12_draw.inl.

No test currently checks these bounds where they apply:

  • The only end-to-end check, startup_logical_view_<adapter>, returns 77 when the adapter accepts the full 1,245,184-descriptor heap. On this machine it skips on WARP 10.0.26100.9818 and on an AMD Radeon RX 6600 (driver 32.0.21045.29003), 3 of 3 runs each.
  • The other WARP draws that reach the code bind a one-record table at its start and read record offset 0.

startup_logical_view_table includes only the header and checks exact windows and records at the boundaries:

  • first, second and last records, a one-record heap and stride 48;
  • handles one past the end, far past it, inside a record and below the heap, including a heap at the top of the address space where the unsigned difference would land on a record;
  • null GPU or CPU start, zero stride and zero count;
  • memory ending exactly at UINT64_MAX (accepted) and one byte past it (rejected), and the full 64-bit count * stride product;
  • record() at a window's first and last records, records crossing the end, a record exactly at the end, UINT64_MAX offset and size, and an unresolved table;
  • both functions together on the final logical record.

The change is test, CMake and docs/startup-runtime.md only. The header and the device code are unchanged.

Verification

Commit 92bd3362 (main) plus this change, dev preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0.

ctest --preset dev --no-tests=error -R '^startup_logical_view_table$' -V
#   startup_logical_view_table ... Passed  (logical view table: windows and records exact)
ctest --preset dev --no-tests=error -R '^startup_logical_view_(hardware|warp)$' -V
#   startup_logical_view_warp ... Skipped, startup_logical_view_hardware ... Skipped (RX 6600), 3 of 3 runs
ctest --preset dev --no-tests=error -R '^startup_(address_srv|stream_draw)_warp$'
#   Passed

tests/docs_links_check.py and tests/bidi_controls_check.py passed.

Mutation probe

I applied each mutation to the header alone, rebuilt startup_stream_consumer (and confirmed the DLL relinked), ran the tests, then reverted. None of this is committed. "Existing" means the 11 WARP tests driven by startup_stream_consumer: ^startup_(stream_request|stream_draw|mrt_.*|logical_view|xg_bc7_draw|slot57_blend_draw|packed_target_draw|address_srv|placed_vertex|address_bc_view)_warp$.

Mutant Existing (WARP) startup_logical_view_table
offset >= bytes → > survived fails
drop offset % stride survived fails
drop cpu > UINT64_MAX - bytes survived fails
record: size <= bytes - offset → < survived fails
record: return address instead of address + offset survived fails
drop handle < gpu survived fails
window length bytes instead of bytes - offset not run fails
32-bit count * stride not run fails

A control mutant where the table never resolves made 4 of the 11 WARP tests fail (xg_bc7_draw, packed_target_draw, address_srv, address_bc_view). So the harness does see this code; it does not check the bounds.

Notes:

  • handle < gpu can only be told apart by a heap near the top of the address space, which is an artificial input.
  • A zero-size record exactly at a window's end (offset == bytes) is deliberately not pinned. Nothing reads such a record, and pinning it would freeze a choice that does not matter.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6581025637 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1450). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T11:45:43Z. --- ## Change Refs #1149. This adds a device-free check for `src/startup_stubs/logical_view_table.h`. The header decides which part of the title's descriptor memory a translated draw may read through a root table handle. `list_table` (list slot 36) calls `resolve_view_table`, and the SRV gather calls `ViewTable::record`, both in `d3d12_draw.inl`. No test currently checks these bounds where they apply: - The only end-to-end check, `startup_logical_view_<adapter>`, returns 77 when the adapter accepts the full 1,245,184-descriptor heap. On this machine it skips on WARP 10.0.26100.9818 and on an AMD Radeon RX 6600 (driver 32.0.21045.29003), 3 of 3 runs each. - The other WARP draws that reach the code bind a one-record table at its start and read record offset 0. `startup_logical_view_table` includes only the header and checks exact windows and records at the boundaries: - first, second and last records, a one-record heap and stride 48; - handles one past the end, far past it, inside a record and below the heap, including a heap at the top of the address space where the unsigned difference would land on a record; - null GPU or CPU start, zero stride and zero count; - memory ending exactly at `UINT64_MAX` (accepted) and one byte past it (rejected), and the full 64-bit `count * stride` product; - `record()` at a window's first and last records, records crossing the end, a record exactly at the end, `UINT64_MAX` offset and size, and an unresolved table; - both functions together on the final logical record. The change is test, CMake and `docs/startup-runtime.md` only. The header and the device code are unchanged. ## Verification Commit `92bd3362` (`main`) plus this change, `dev` preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0. ```powershell ctest --preset dev --no-tests=error -R '^startup_logical_view_table$' -V # startup_logical_view_table ... Passed (logical view table: windows and records exact) ctest --preset dev --no-tests=error -R '^startup_logical_view_(hardware|warp)$' -V # startup_logical_view_warp ... Skipped, startup_logical_view_hardware ... Skipped (RX 6600), 3 of 3 runs ctest --preset dev --no-tests=error -R '^startup_(address_srv|stream_draw)_warp$' # Passed ``` `tests/docs_links_check.py` and `tests/bidi_controls_check.py` passed. ## Mutation probe I applied each mutation to the header alone, rebuilt `startup_stream_consumer` (and confirmed the DLL relinked), ran the tests, then reverted. None of this is committed. "Existing" means the 11 WARP tests driven by `startup_stream_consumer`: `^startup_(stream_request|stream_draw|mrt_.*|logical_view|xg_bc7_draw|slot57_blend_draw|packed_target_draw|address_srv|placed_vertex|address_bc_view)_warp$`. | Mutant | Existing (WARP) | `startup_logical_view_table` | |---|---|---| | `offset >= bytes` → `>` | survived | fails | | drop `offset % stride` | survived | fails | | drop `cpu > UINT64_MAX - bytes` | survived | fails | | `record`: `size <= bytes - offset` → `<` | survived | fails | | `record`: return `address` instead of `address + offset` | survived | fails | | drop `handle < gpu` | survived | fails | | window length `bytes` instead of `bytes - offset` | not run | fails | | 32-bit `count * stride` | not run | fails | A control mutant where the table never resolves made 4 of the 11 WARP tests fail (`xg_bc7_draw`, `packed_target_draw`, `address_srv`, `address_bc_view`). So the harness does see this code; it does not check the bounds. Notes: - `handle < gpu` can only be told apart by a heap near the top of the address space, which is an artificial input. - A zero-size record exactly at a window's end (`offset == bytes`) is deliberately not pinned. Nothing reads such a record, and pinning it would freeze a choice that does not matter. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 12:03:06 +00:00
tedin7 commented 2026-11-24 12:03:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:54:46Z.

Review: COMMENTED


Reviewed commit 1c3842a62ff140d904c48adb3997f48afa1272b0 (git diff origin/main...HEAD). Clean, focused test + docs addition; no issues found.

Checks

  • Linux: python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, and git diff --check origin/main..HEAD passed. Title-neutrality clean.
  • Win2025 (Build 26100, MSVC 14.44.35207):
    • Debug (--preset dev): startup_logical_view_table_check built (3.10s); ctest -R '^startup_logical_view_table$' 1/1 passed (0.01s).
    • Release /O2 (--preset release): built (0.44s); 1/1 passed (0.01s).

Audit

  • tests/startup_logical_view_table_check.cpp directly exercises x2w_startup::resolve_view_table and ViewTable::record across boundary cases (first/last records, 64-bit UINT_MAX * UINT_MAX product, UINT64_MAX address-space wraparound, unaligned/out-of-range handles, null/zero inputs, and out-of-bounds/overflowing record offsets and sizes) without modifying src/startup_stubs/logical_view_table.h.
  • docs/startup-runtime.md accurately documents the reproduction command and scope.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6038720440 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1450#pullrequestreview-6038720440). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T11:54:46Z. **Review:** COMMENTED --- Reviewed commit `1c3842a62ff140d904c48adb3997f48afa1272b0` (`git diff origin/main...HEAD`). Clean, focused test + docs addition; no issues found. ### Checks - **Linux**: `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, and `git diff --check origin/main..HEAD` passed. Title-neutrality clean. - **Win2025 (Build 26100, MSVC 14.44.35207)**: - **Debug (`--preset dev`)**: `startup_logical_view_table_check` built (`3.10s`); `ctest -R '^startup_logical_view_table$'` **1/1 passed** (`0.01s`). - **Release `/O2` (`--preset release`)**: built (`0.44s`); **1/1 passed** (`0.01s`). ### Audit - `tests/startup_logical_view_table_check.cpp` directly exercises `x2w_startup::resolve_view_table` and `ViewTable::record` across boundary cases (first/last records, 64-bit `UINT_MAX * UINT_MAX` product, `UINT64_MAX` address-space wraparound, unaligned/out-of-range handles, null/zero inputs, and out-of-bounds/overflowing record offsets and sizes) without modifying `src/startup_stubs/logical_view_table.h`. - `docs/startup-runtime.md` accurately documents the reproduction command and scope.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
R0Y00/Xbox2Windows!1443
No description provided.