mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-10-22 06:12:35 +00:00
Windows: fix KDF completion lifetime
Hold a requester reference until header parsing can no longer enqueue KDFs. This prevents stale completion signals from allowing cleanup while workers still use request-owned state. Add bounded tests of the production pool and caller completion protocol.
This commit is contained in:
@@ -291,6 +291,7 @@ static TC_THREAD_PROC EncryptionThreadProc (void *threadArg)
|
||||
InterlockedExchange (workItem->KeyDerivation.CompletionFlag, TRUE);
|
||||
TC_SET_EVENT (*workItem->KeyDerivation.CompletionEvent);
|
||||
|
||||
// The requester retains a reference until it has finished submitting work.
|
||||
if (InterlockedDecrement (workItem->KeyDerivation.OutstandingWorkItemCount) == 0)
|
||||
TC_SET_EVENT (*workItem->KeyDerivation.NoOutstandingWorkItemEvent);
|
||||
|
||||
@@ -581,7 +582,6 @@ void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT
|
||||
workItem->KeyDerivation.pAbortKeyDerivation = pAbortKeyDerivation;
|
||||
|
||||
InterlockedIncrement (outstandingWorkItemCount);
|
||||
TC_CLEAR_EVENT (*noOutstandingWorkItemEvent);
|
||||
|
||||
SetWorkItemState (workItem, WorkItemReady);
|
||||
TC_SET_EVENT (WorkItemReadyEvent);
|
||||
|
||||
Reference in New Issue
Block a user