D3D12.X: TOCTOU use-after-free on RTVS resource pointer in present::note_execute #2381
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#2381
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?
@ahmetbagci8 on GitHub · 2026-11-25 17:32 UTC · original
Summary
In
crates/xcl/src/hle/d3d12x/present.rs,note_executereads a raw COM resource pointerresout ofRTVSand dropsRTVS.lock()without callingadd_ref(res)(lines 276-288):Meanwhile,
note_rtv(lines 158-171) removes or replaces entries inRTVSunderRTVS.lock()and callsrelease(o):If another thread calls
note_rtv(h, ...)betweennote_executereleasingRTVS.lock()(line 276) and callingbackbuffer_like(res)(line 278) /add_ref(res)(line 284), andRTVSheld the last reference,resis freed beforenote_executedereferences its COM vtable (TOCTOU use-after-free).Suggested fix
Acquire a reference while still holding
RTVS.lock(), and release it on early return or ifCANDIDATEalready holdsres:Not tested
082944135cd2b96288470a595861fa608eee08dcwithout a new runtime test.AI use
present.rsand drafted this report; the author reviewed it before posting.