xasync: prevent use-after-free on XAsyncCancel in pending_with and concurrent XAsyncGetResult #677
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!677
Loading…
Reference in a new issue
No description provided.
Delete branch "MasterWolf/Darner:pr/post-merge-xasync-cancel-uaf"
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?
Not run in the game (verified via
cargo test,cargo clippy, andcargo buildon2ee54ba; concurrency/cancel paths covered by unit tests).Contributor role (optional)
What it changes
post-merge: read fromcrates/darner-hle/src/modules/xasync.rs(28a9b42):pending_withpasses a rawBox<Data>pointer toXAsyncBeginand moves rawstate: usize/block: usizeinto a spawned worker thread. CallingXAsyncCancelwhilework()is running invokesrelease(block)->OP_CLEANUP, freeingDatawhile the worker still writes into it (heap UAF) and later callsXAsyncComplete(block, ...)which can match a reusedAsyncBlock(corrupting the new call).XAsyncGetResultclonesArc<Call>fromCALLSand callsrelease(block)only afterOP_GET_RESULT. Two concurrent callers can raceOP_GET_RESULTagainstOP_CLEANUP, freeing the provider context in use.This PR:
complete_call(&Arc<Call>, ...)andrelease_call(block, &Arc<Call>)(Arc::ptr_eq-guarded removal) so stale completions lockcall.donewithout touchingblockor evicting a reused call.pending_withfromBox<Data>toArc<Data>, cloning bothArc<Data>andArc<Call>inOP_BEGINfor the worker thread and completing viacomplete_call.XAsyncGetResultvalidateidentityand buffer size underCALLSlock, then atomically remove theArc<Call>before invokingOP_GET_RESULTandOP_CLEANUP.pending_with_cancel_while_running_neither_uafs_nor_corrupts_reused_block,pending_with_completes_and_delivers_payload,get_result_buffer_too_small_keeps_call_alive_and_concurrent_get_result_runs_once).How it was tested
2ee54ba(onpost-merge28a9b42)cargo test --offline -p darner-hle --lib modules::xasync—3 passed; 0 failed(0.00s)cargo clippy --offline -p darner-hle --tests— passed (0warnings indarner-hle)cargo build --offline -p darner— passed (12.02s)cargo build,cargo test,cargo clippyChecklist
cargo clippy, andcargo build).post-merge.Checked for overlap
[pr-fix][hle] xasync: prevent use-after-free on XAsyncCancel in pending_with and concurrent XAsyncGetResultto xasync: prevent use-after-free on XAsyncCancel in pending_with and concurrent XAsyncGetResultView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.