HLE: prevent concurrent XAsyncGetResult use-after-free and XAsyncBegin overwrite leak #2551
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2551
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2551/head"
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?
@reeledMarek on GitHub · 2026-11-25 15:40 UTC · original
reeledMarek:fix/hle-xasync-getresult-uaf-and-begin-race→main· +106 −27 · 1 files · 1 commits · closed without mergingProblem
XAsyncGetResultuse-after-free:XAsyncGetResultclonedArc<Call>fromCALLS, invokedOP_GET_RESULTunlocked, and only afterward calledrelease(block)(OP_CLEANUP). Two threads racingXAsyncGetResulton the same completed block could executeOP_GET_RESULTconcurrently while the first thread'sOP_CLEANUPfreed the provider context.XAsyncBeginoverwrite leak:XAsyncBegincheckedcall(block)and inserted intoCALLSunder separate lock acquisitions, allowing two racingXAsyncBegincalls on the same block to overwrite and leak the first call withoutOP_CLEANUP.Fix
XAsyncGetResult, validate identity and buffer size and remove the entry fromCALLSatomically under one lock (leaving the entry intact onE_NOT_SUFFICIENT_BUFFERorE_INVALIDARG), then invokeOP_GET_RESULTandOP_CLEANUPon the exclusively ownedCall.XAsyncBegin, serialize the existing-call check and insertion under a singleCALLSlock (usingtry_lockonleft.doneso lock ordering withcomplete_callis never inverted) and run staleOP_CLEANUPafter unlocking.Testing
concurrent_get_result_claims_result_and_runs_cleanup_onceincrates/victory-hle/src/modules/xasync.rs.cargo test -p xtask --lockedpasses asset policy.@Marvisak on GitHub · 2026-11-25 18:36 UTC · original
Automated triage for the maintainers.
Needs work: please add evidence. In
crates/victory-hle/src/modules/xasync.rs,XAsyncGetResultnow takes theCallout ofCALLSunder one lock beforeOP_GET_RESULT/OP_CLEANUP.XAsyncBeginnow checks for a call left behind and inserts the new one under one lock, usingtry_lockonleft.done. I checked the lock order:complete_callholdscall.doneand then takesCALLS(throughrelease). The newtry_lockavoids the inversion, and I found no deadlock.Both races, though, need the title to use one async block from two threads at once: two
XAsyncGetResultcalls on the same completed block, or twoXAsyncBegincalls on the same block. One block carries one call, so a title that follows the API would not do this. The PR gives no sign that the title does. The new testconcurrent_get_result_claims_result_and_runs_cleanup_onceshows the new code's behaviour, not something the title needs. The change also alters the order of events: the call is now gone fromCALLSwhile the provider'sOP_GET_RESULTruns. What would change the verdict: a log or trace from a run showing two threads on one block, or a reference for what the runtime does in that case.CI: the
checkrun passed on the current head.Generated by Claude Code
@reeledMarek on GitHub · 2026-11-25 20:05 UTC · original
Closing per triage — concurrent same-block
XAsyncGetResult/XAsyncBeginviolates single-owner API usage without evidence of a title doing this. Thanks for the review!Pull request closed