GPU/queue: hold Queue::held behind Arc and Weak in WAITING to eliminate release/release_held UAF #620
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T03:25:53Z.
Problem
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
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.