D3D12.X: bounds-check readback reads in present::write_frame #1414
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1424"
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 ivall/xcl. Originally posted by b3IKK on 2026-11-24T15:48:50Z.
present::write_frameunconditionally indexedfp.Offset + step * y * pitch + 4 * step * xas a 4-byte texel for allx < w / step,y < h / step. For 1/2-bpp intermediate render targets (e.g.R8_UNORM,R16_FLOAT) dumped byXCL_TRACE_FRAME,4 * step * xexceedsRowPitch; for block-compressed targets whose readback footprint contains onlyceil(Height / 4)block-rows,step * y * pitchreads past the end of the mapped readback buffer.This adds
readback_texel_offset()checking bothrow_off + 4 <= RowPitchandoff + 4 <= rb.GetDesc().Widthwith checked arithmetic, treating out-of-bounds samples as undecoded rather than reading past the mapped buffer.What is in it
crates/xcl/src/hle/d3d12x/present.rs: addreadback_texel_offset()and use it inwrite_frame; add unit testreadback_texel_offset_bounds_checks_narrow_and_bc_footprints.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib readback_texel_offset_bounds_checks_narrow_and_bc_footprints: 1 passed, 0 failedRegression run
main:
PR:
Not tested
AI use
present.rs, wrote the fix and unit test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:58:05Z.
Full-suite run, since this PR has no test report yet. Tested exact head
39b7e4e(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.readback_texel_offset_bounds_checks_narrow_and_bc_footprints.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T17:21:27Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
Imported from ivall/xcl. Originally posted by grahamster2 on 2026-11-25T00:48:44Z.
Tested
39b7e4e(CPU tests only, no game run): RTX 3080 10 GB (610.88), Ryzen 5 7600X, Windows 11 26200, rustc 1.94.0, debug.cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored; SKIPPED: 2 (no wave64).6567c5f): no conflicts;cargo test -p xcl --lib present::7 passed, includingreadback_texel_offset_bounds_checks_narrow_and_bc_footprints.write_frameitself. A test that maps a small R8 footprint throughwrite_framewould pin the end-to-end behaviour. Taking the stride from the format would be a separate follow-up.Not tested: AMD, and a game run with
XCL_FRAME_DUMP_FULL=1.Claude Code with Claude Opus 5.5 ran the tests and wrote this note.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T08:01:11Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:42:39Z.
Triage (#1607) – head
39b7e4eMain fixed the out-of-bounds read another way: commit
337c3094(merged with #3203) makeswrite_frameread each sample atbytes * step * xwithbytes = targets::texel_bytes(format), so a 1- or 2-byte target no longer runs past its row. The fixed 4-byte read this PR bounds-checks is gone, so the PR conflicts and its helper would read at the wrong stride now.The BC case in the test does not reach
write_frame, which only dumps render targets and the frame.Recommendation: close (superseded by main commit
337c309).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:45:58Z.
Closing as superseded: this change is already on
main(337c3094). main present.rs write_frame reads each texel at its own size via targets::texel_bytes, row index scaled by bytes; the 1-2 byte over-read is gone (PR's BC-format bounds check not needed for render-target dumps)Two independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed