Guard slice footprint byte spans and uploads against invalid indices #1487
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1494"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:54:27Z.
Change
SliceFootprints::bytes(i)computedRowPitch * (Depth * rows[i] - 1) + row_bytes[i]unconditionally. For an index past the arrays it read out of bounds, and for an entry that was never filled (no device, unsupported format, mip count 0 or above 15) or with zero rows or depth the unsigned subtraction wrapped to a value near 2^64.SliceFootprints::upload()divided by the mip count (i % mips,i / mips), so 0 mips divided by zero, and it did not check the object pointers, the slice, the plan index or the plan size.bytes()returns 0 (nothing to span) for an index past the 30 entries, and for rows or depth of 0. A pitch of 0 still spans one row.upload()returns without copying for a missing list, texture or upload buffer, 0 or more than 15 mips, 0 slices, a slice past the slices, a plan index past the plan, or a plan without a size. Valid requests are unchanged. The mips bound also keeps the subresource index within 32 bits (at most about 2 million).bytes()is the array capacity, notcount, on purpose: the open PR #1486 sets entries by hand on a plan built without a device (count 1) and callsbytes(29). That test passes unchanged with this header (51 cases, run locally). No file overlap with #1486.Verification
Test added to
tests/startup_plane_refresh.cpp(check_footprint_guards, runs before any device is created): plans filled by hand for one plane and for NV12, with expected byte counts written out; invalid indices, rows 0, depth 0, pitch 0, unset plan;upload()through a stand-in command list whose only live method isCopyTextureRegion(any other method ends the run), with the expected subresource index computed by the D3D12 subresource definition (mip + slice * mips + plane * mips * slices), and nine refused requests that must make no call.Executed locally (MinGW g++ 14 x86_64, run under Wine; the GPU part of the file is not run there):
slice footprint guards: PASS, exit 0.i >= max_mips * 2guard removed: stack overflow from the out-of-range read. With the rows/depth guard removed: FAIL "no rows", "no depth". With the!mipscheck removed: divide by zero. Withi >= countremoved: FAIL "subresource past the plan" then crash. Withsize == UINT64_MAXremoved: FAIL "a plan without footprints copies nothing".startup_slice_footprints_check) built against this header: PASS (51 cases).git diff --check: clean.Not run here: the Windows GPU part (
startup_plane_refresh_warp,startup_nv12_draw_warp). These are outside--preset pr; run on the Windows node:ctest --preset dev --no-tests=error -R "^(startup_plane_refresh|startup_nv12_draw)_warp$" -V.Evidence and follow-up
x2w_pipe.py preflightis blocked by a local command hook, so title, overlap and secrets were checked by hand.AI-assisted; commands listed were executed locally.
Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:03:19Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
4da7bd7f93d747a38954b374ea40400ad254aec1:--preset dev):ctest --preset dev -R '^startup_plane_refresh_' --parallel 4 --no-tests=error --output-on-failure: 2/2 passed (startup_plane_refresh_hardware,startup_plane_refresh_warp)/O2(--preset release):ctest --preset release -R '^startup_plane_refresh_' --parallel 4 --no-tests=error --output-on-failure: 2/2 passedorigin/main;git diff --checkandtests/bidi_controls_check.pyclean; GitHub CI green.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T13:03:28Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
4da7bd7ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T13:30:30Z.
Maintainer update at
982e0303checks 64-bit byte spans and calculates the destination index before narrowing to UINT. The source-built overflow controls and both Windows Release plane refresh cases passed on RTX and WARP (2/2).