XGameRuntime: use-after-free in XUserRegisterForDeviceAssociationChanged / Unregister #1389
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#1389
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?
@microwave805 on GitHub · 2026-11-24 15:31 UTC · original
Checked on
main(930e8b4).Problem
In
crates/xcl/src/hle/xgameruntime/mod.rs:851-923:XUserUnregisterForDeviceAssociationChangedignores_waitand returnstrueimmediately without waiting for any in-flightassociation_callor preventing already-queuedAssociationCallitems from invokingr.cb.association_callignores_canceledand never checks whether the registration is still active — so even terminating the task queue (XTaskQueueTerminate, which passescanceled = true) still invokesf(r.ctx, &r.change).897-901vs915-922readUSER_SIGNED_INoutsideASSOCIATION_CALLBACKS's mutex, so a concurrent sign-in and register can submit the same callback twice.Minimal trigger
XUserRegisterForDeviceAssociationChanged(queue, ctx, cb, &mut token)on a manual or thread-pool completion port sonotify_associationqueues anAssociationCall.XUserUnregisterForDeviceAssociationChanged(token, /*wait=*/true)and freectx(valid per GDK contract oncewait = truereturnstrue).XTaskQueueTerminate) →association_callinvokescb(ctx, &change)on the freedctx.Suggested fix
Track each registration with an
Arcstate holdingstopped,in_flight, and aCondvar(mirroringCallbackEntryincrates/xcl/src/hle/gameinput.rs:658-751), bail out ofassociation_callwithout callingfwhencanceled || stopped(still droppingBox<AssociationCall>), wait whilewait && in_flight > 0on unregister, and check/updateUSER_SIGNED_INunder the same lock asASSOCIATION_CALLBACKS.AI use: Antigravity (Gemini 4 Neon) performed the read-only source audit and drafted this issue; checked and verified on
930e8b4before opening.github-bot referenced this issue2026-11-26 04:59:09 +00:00