mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-10-22 06:12:35 +00:00
Unix: synchronize encryption fragment exceptions
Serialize updates to the shared exception pointer and retain the first reported error. Test concurrent failures through all three handlers, exception cleanup and subsequent successful work.
This commit is contained in:
@@ -344,21 +344,33 @@ namespace VeraCrypt
|
||||
if (workItem->Type == WorkType::DeriveKey)
|
||||
workItem->KeyDerivation.WorkItem->ItemException.reset (e.CloneNew());
|
||||
else
|
||||
workItem->FirstFragment->ItemException.reset (e.CloneNew());
|
||||
{
|
||||
ScopeLock exceptionLock (FragmentExceptionMutex);
|
||||
if (!workItem->FirstFragment->ItemException.get())
|
||||
workItem->FirstFragment->ItemException.reset (e.CloneNew());
|
||||
}
|
||||
}
|
||||
catch (exception &e)
|
||||
{
|
||||
if (workItem->Type == WorkType::DeriveKey)
|
||||
workItem->KeyDerivation.WorkItem->ItemException.reset (new ExternalException (SRC_POS, StringConverter::ToExceptionString (e)));
|
||||
else
|
||||
workItem->FirstFragment->ItemException.reset (new ExternalException (SRC_POS, StringConverter::ToExceptionString (e)));
|
||||
{
|
||||
ScopeLock exceptionLock (FragmentExceptionMutex);
|
||||
if (!workItem->FirstFragment->ItemException.get())
|
||||
workItem->FirstFragment->ItemException.reset (new ExternalException (SRC_POS, StringConverter::ToExceptionString (e)));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (workItem->Type == WorkType::DeriveKey)
|
||||
workItem->KeyDerivation.WorkItem->ItemException.reset (new UnknownException (SRC_POS));
|
||||
else
|
||||
workItem->FirstFragment->ItemException.reset (new UnknownException (SRC_POS));
|
||||
{
|
||||
ScopeLock exceptionLock (FragmentExceptionMutex);
|
||||
if (!workItem->FirstFragment->ItemException.get())
|
||||
workItem->FirstFragment->ItemException.reset (new UnknownException (SRC_POS));
|
||||
}
|
||||
}
|
||||
|
||||
if (workItem->Type == WorkType::DeriveKey)
|
||||
@@ -409,6 +421,7 @@ namespace VeraCrypt
|
||||
|
||||
Mutex EncryptionThreadPool::EnqueueMutex;
|
||||
Mutex EncryptionThreadPool::DequeueMutex;
|
||||
Mutex EncryptionThreadPool::FragmentExceptionMutex;
|
||||
Mutex EncryptionThreadPool::KeyDerivationCompletionMutex;
|
||||
|
||||
SyncEvent EncryptionThreadPool::WorkItemReadyEvent;
|
||||
|
||||
@@ -111,6 +111,8 @@ namespace VeraCrypt
|
||||
static volatile size_t DequeuePosition;
|
||||
static volatile size_t EnqueuePosition;
|
||||
static Mutex EnqueueMutex;
|
||||
// Fragments of one request share the first fragment's exception pointer.
|
||||
static Mutex FragmentExceptionMutex;
|
||||
// Orders KDF outstanding-count transitions against no-outstanding event updates.
|
||||
static Mutex KeyDerivationCompletionMutex;
|
||||
static list < shared_ptr <Thread> > RunningThreads;
|
||||
|
||||
Reference in New Issue
Block a user