HLE/dstorage: retain IDStorageFile ref and own Request.name on enqueued reads #403
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/403"
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-25T00:25:33Z.
Problem
In
crates/victory-hle/src/modules/dstorage.rs,enqueue_requestcopied the caller'sRequestby value without retaining a COM reference onrequest.source(Instance<File>) or copyingrequest.name:IDStorageFileUAF: Unlikeenqueue_status(which callsadd_ref_instanceon the status array and releases it inStatus::drop),enqueue_requestdid not retainrequest.sourcefor file-backed reads (options & MEMORY_SOURCE == 0). If the title calledIDStorageFile::Release()afterEnqueueRequest,Instance<File>and its OSFilehandle were freed immediately before the worker thread ranread_into.Request::nameUAF:request.name(*const c_char) was copied as a raw pointer and dereferenced asynchronously on the worker thread inexecute'sfailclosure, even thoughDSTORAGE_REQUEST::Nameonly needs to outliveEnqueueRequest.Fix
Command::Read(Request),Lane::readsentries, andJob::requestwith an ownedQueuedReadthat:request.nameeagerly viatext(request.name)and nullsrequest.name.add_ref_instanceonrequest.sourcewhenoptions & MEMORY_SOURCE == 0 && !source.is_null().execute(before acquiringscheduler.lock()and signaling status completion) and inDrop(covering unstarted reads discarded byCloseor a closed queue).dstorage::tests::enqueued_request_retains_file_and_copies_name_until_completion.Verification
cargo test -p victory-hle --locked dstorage -- --test-threads=1: 14 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-hle --all-targets --locked -- -D warnings: cleancargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings: clean(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.