GPU/queue: hold Queue::held behind Arc and Weak in WAITING to eliminate release/release_held UAF #620
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!620
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-620"
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?
@AscilCH on GitHub · 2026-11-25 03:25 UTC · original
AscilCH:fix/gpu-queue-waiting-arc-held-no-uaf→main· +118 −28 · 1 files · 1 commits · openProblem
In
crates/victory-gpu/src/queue.rs,WAITING: Mutex<Vec<usize>>stored raw*const Queuepointers without holding any lifetime guarantee:release(),object::release_boxed::<Queue>(this)dropped and freedBox<Queue>(and its embeddedheld: Mutex<Vec<Held>>) before removingthisfromWAITING.release_held(), raw pointers were cloned out ofWAITINGand dereferenced viaunsafe { &(*(q as *const Queue)).held }while locking the mutex acrosshost.execute(&runs)with no synchronization against a concurrentID3D12CommandQueue::Release().If one thread released a waiting queue while another thread ran
release_held(),release_held()could dereference freed memory, lock a destroyedMutex, or drop aMutexGuardonto freed memory. In addition, removing by raw address afterrelease_boxedrisked removing a newerQueueallocated at the same address (ABA).Fix
Queue::heldtoArc<Mutex<Vec<Held>>>and changeWAITINGto store(usize, Weak<Mutex<Vec<Held>>>)entries.register_waiting(this)to register(id, Arc::downgrade(&queue(this).held))(replacing any stale entry for the same address).release(), downgradequeue(this).heldbeforerelease_boxed::<Queue>(this), and remove only the matchingWeak::ptr_eqentry whenleft == 0.release_held(), upgrade eachWeakhandle safely instead of dereferencingq as *const Queue, pruning dead entries viaWeak::ptr_eq.releasing_waiting_queue_prunes_waiting_and_never_uafs_on_release_heldandconcurrent_release_held_and_queue_release_do_not_uaf.Verification
cargo test -p victory-gpu --locked queue::tests -- --test-threads=1: 6 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean (default-features build onc96b4f2has only the pre-existingdead_codewarning onplaced_filler_twins, tracked in #491)(AI-assisted; synthetic unit tests only, no game data.)
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.