mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:25:52 +01:00
[PR #1387] [CLOSED] d3d12_xs: slot 14 takes the console layout only for committed, writable descriptor memory #1415
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1415
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1387
Author: @JoshRob297
Created: 11/25/2026
Status: ❌ Closed
Base:
main← Head:fix/descriptor-heap-validated-console-layout📝 Commits (1)
60b0ead[PATCH] d3d12_xs: take the console slot-14 layout only for backed📊 Changes
2 files changed (+91 additions, -14 deletions)
View changed files
📝
runtime/shims/d3d12_xs_device.cpp(+50 -13)📝
runtime/test/d3d12_console_descriptor_heap_test.cpp(+41 -1)📄 Description
d3d12_xs: slot 14 takes the console layout only for committed, writable descriptor memory
Fixes #3.
The false positive reported here has a second shape after #4: a size-only guard accepts a plain PC
D3D12_DESCRIPTOR_HEAP_DESCwhose trailing caller words happen to be(1, 32), soGetCPUDescriptorHandleForHeapStart()returns address 1 (#1148). This replaces the shape test with acheck on the memory the console layout names.
What changes
runtime/shims/d3d12_xs_device.cppcommitted_writable_range(address, bytes): walks the range withVirtualQuery, requiring everypage to be
MEM_COMMITwithPAGE_READWRITEorPAGE_WRITECOPY.console_heap_range_plausible()now takes the heap's actual increment and accepts the console layoutonly when all of these hold:
addressis a user-mode address (>= 0x10000, below the canonical user limit);NumDescriptors != 0and does not overflow;size == 0(caller left it unset) orsize == NumDescriptors * increment, usingGetDescriptorHandleIncrementSize(desc->Type)(32 for CBV/SRV/UAV and RTV, as measured);[address, address + NumDescriptors * increment)is committed and writable.trailer: no address is applied, and an ordinary PC heap is created.
runtime/test/d3d12_console_descriptor_heap_test.cppVirtualAlloc, instead of using theunmapped constant
0x556677880000. A console heap is backed by title memory; after this change anunbacked address is no longer a console heap, so the test has to hand it real memory.
NumDescriptors = 1followed by the words(1, 32)must reach the PC path, and its CPU heap start must not be 1.Why this is a positive check, not a heuristic
The console layout is not identified by the bytes after the PC description; those bytes are the
caller's, and any readable non-zero word there is a coincidence. It is identified by what the pair
(address, size)claims: descriptor memory the title owns for this heap. That claim is checkable:VirtualQuery, not a readable probe of one word);A PC caller's trailing words are arbitrary. The only way they satisfy all three conditions is if the
caller really holds a committed, writable buffer of exactly
NumDescriptors * incrementbytes at theword after its descriptor, which is the console layout's contract. The shapes that produced the
reported crashes — address 1, or an unbacked synthetic address with a matching size — are rejected by
construction, not by a threshold.
Negative control, measured: with the previous size-only rule restored, the new
(1, 32)case takesthe console layout (
descriptor heap takes the console address 0x1 (size 32)) and the test fails withCPU start 0x1. With this change the same case reaches the PC path and both tests pass.Measurement on the retail title
The call that motivated the console path carries, after the 16-byte PC description:
0x1000039845888NumDescriptors124518432NumDescriptors * 3239845888[0x10000, 0x10000 + 39845888)is committed and writable in the title, so the validated check acceptsthe layout and the heap keeps the console address. The same numbers pass the size comparison alone,
which is why the size rule was necessary but not sufficient.
Build and test
Base:
upstream/mainat0f98d193c(the working mirror was 137 commits behind, so the branch was cutfrom upstream to keep the patch applicable).
Built with clang-cl 23.1.4 + xwin, run under Wine 11.22 (Staging) on an Intel Graphics (MTL) Vulkan
device.
d3d12_descriptor_test(ctestd3d12_descriptor)d3d12_console_descriptor_heap_test(1, 32)regression with the size-only guardCPU start 0x1(1, 32)regression with this changeThe SEGFAULT in the report is GPU/driver-specific and does not reproduce on this Intel MTL box:
upstream main already exits 0 here, matching the report from another machine on current main. The
regression is therefore demonstrated by the
(1, 32)case, which fails under the size-only guard andpasses here.
Not run: the full
ctestsuite (278+ tests), and the retail title on this machine. No game data isincluded.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.