HLE: prevent concurrent XAsyncGetResult use-after-free and XAsyncBegin overwrite leak #2549
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2551"
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 Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T15:40:10Z.
Problem
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.upstream-sync referenced this pull request2026-11-25 17:05:03 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T18:36:29Z.
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
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T20:05:41Z.
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