era_gpu_alias: validate full committed span before calling D3D12 #1511
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1518"
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-24T13:30:00Z.
Summary
src/era_gpu_alias.cpp: inera_gpu_alias::open, validate thatbase + sizedoes not wrapstd::uintptr_tand walk[base, base + size)withVirtualQueryto verify every region in the span belongs tobase's allocation (AllocationBase == base), is committed (MEM_COMMIT), has a valid non-zero region coveringcursor, and is accessible (notPAGE_NOACCESS,PAGE_GUARD, or protection0) before calling D3D12. Previously only the firstMEMORY_BASIC_INFORMATIONregion was checked, allowing oversized spans, address-space wraps, partially committed reservations, andPAGE_NOACCESS/PAGE_GUARDtails to reachOpenExistingHeapFromAddress.tests/gpu_alias.cpp: add negative controls for nulldevice/base, zerosize, oversizedsize, address-space wrap, partially committed reservations, andPAGE_NOACCESS/PAGE_GUARDcommitted tails.tests/era_physical_check.cpp: add negative controls for invalidera_physical::allocateandera_physical::releasearguments (null buffers, zero/oversized counts, invalid flags including upper 32 bits, out-of-range page numbers).Verification
AI-assisted; commands listed were executed locally.
git diff --check origin/main...HEADpython3 tests/docs_links_check.pypython3 tests/bidi_controls_check.py/O2verification posted below.Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T13:37:38Z.
Ownership check is covered; the wrap guard turns out to be redundant with the span walk
Independent reviewer, not the author. Reviewed
57d3e2d5; nothing pushed to the branch. Mutations were made locally insrc/era_gpu_alias.cpp, rebuilt, reverted; working tree is clean.Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100.
4 of 4 pass, and
era_physical_controlsprints all seven policy/lenient rows as before.Mutation A — the ownership half of the walk
Good: the
AllocationBase == baserequirement is what makes a foreign committed span fail, and two cases notice itsabsence. That is the part of the change I most wanted to see exercised, and it is.
Mutation B — the wrap guard
Nothing fails, and I do not read that as a coverage gap. The control that is meant to cover this is
open(device, base, UINT64_MAX, interior), and with the guard gone theVirtualQuerywalk still refuses that input,because the span cannot be committed past the end of the address space. So the two checks are redundant for the input you
test, and the fixture asserts the observable (refusal with
E_INVALIDARG), not which check produced it.Worth knowing rather than fixing: the wrap guard could be deleted without any test changing colour, so it is
belt-and-braces. If you want it to stay, a one-line comment saying it exists to reject the input before the walk touches
it would explain why both are there. If you would rather have it covered by its own observation, that needs a seam that
lets a test observe which branch refused — I would not add that for this.
Verdict
Reviewed
57d3e2d5. Builds clean, the four cases pass, the ownership check is genuinely exercised, and the only part notdistinguishable by the fixture is redundant rather than unprotected. No objection from me.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:41:49Z.
Thanks
@ChazY11for the independent review and mutation testing! Good catch on Mutation B — the upfrontuintptr_twrap check is intentionally belt-and-braces to reject wrapping spans in O(1) before walkingVirtualQueryand to keep thecursor + coveredloop invariant overflow-free.In
5f57a8d7(rebased ontomain),era_gpu_alias::openwas also tightened to reject committed regions withPAGE_NOACCESS,PAGE_GUARD, or protection0(with matching negative controls intests/gpu_alias.cpp), and local-path wording was removed from the PR body.AI-assisted; commands listed were executed locally.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
5f57a8d77a21de8f6475013f69c39edca46a6616:--preset dev):cmake --build --preset dev --target offscreen_check era_physical_check era_title_gpu_alloc_check -- -j 6):27.75s(configure0.00s)ctest --preset dev -R '^(gpu_alias.*_warp|era_physical_|era_title_gpu_alloc)' --parallel 4 --no-tests=error --output-on-failure): 8/8 passed (0.35s:gpu_alias_lookup_writes_warp0.06s,gpu_alias_warp0.07s,gpu_alias_registry_warp0.07s,era_physical_controls0.01s,era_title_gpu_alloc0.02s,gpu_alias_lookup_warp0.05s,gpu_alias_window_warp0.05s,era_physical_lifetime0.27s)/O2(--preset release):cmake --build --preset release --target offscreen_check era_physical_check era_title_gpu_alloc_check -- -j 6):39.00s(configure0.00s)ctest --preset release -R '^(gpu_alias.*_warp|era_physical_|era_title_gpu_alloc)' --parallel 4 --no-tests=error --output-on-failure): 8/8 passed (0.20s:gpu_alias_window_warp0.04s,gpu_alias_lookup_writes_warp0.06s,gpu_alias_lookup_warp0.06s,era_title_gpu_alloc0.01s,era_physical_controls0.01s,era_physical_lifetime0.11s,gpu_alias_warp0.05s,gpu_alias_registry_warp0.06s)sccache: 90/100 hits; wall72.9sImported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T13:42:00Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
5f57a8dℹ️ 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.