summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2021-01-08 13:48:13 +0000
committerMatt Caswell <matt@openssl.org>2021-01-14 17:30:46 +0000
commitf5a50c2a07e288187c14b784be253b3a2a23483b (patch)
tree71ab229bb6194a7dde63dcf5fa904f5bef005158 /doc
parent2c40421440d260ddb97a807b064033f61ae3b2b3 (diff)
Enable locking on the primary DRBG when we create it
The primary DRBG may be shared across multiple threads and therefore we must use locking to access it. Previously we were enabling that locking lazily when we attempted to obtain one of the child DRBGs. Part of the process of enabling the lock, is to create the lock. But if we create the lock lazily then it is too late - we may race with other threads where each thread is independently attempting to enable the locking. This results in multiple locks being created - only one of which "sticks" and the rest are leaked. Instead we enable locking on the primary when we first create it. This is already locked and therefore we cannot race. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13660)
Diffstat (limited to 'doc')
-rw-r--r--doc/man3/EVP_RAND.pod4
1 files changed, 3 insertions, 1 deletions
diff --git a/doc/man3/EVP_RAND.pod b/doc/man3/EVP_RAND.pod
index e53cddff2f..4e1eb88afd 100644
--- a/doc/man3/EVP_RAND.pod
+++ b/doc/man3/EVP_RAND.pod
@@ -152,7 +152,9 @@ appropriate size.
EVP_RAND_enable_locking() enables locking for the RAND I<ctx> and all of
its parents. After this I<ctx> will operate in a thread safe manner, albeit
-more slowly.
+more slowly. This function is not itself thread safe if called with the same
+I<ctx> from multiple threads. Typically locking should be enabled before a
+I<ctx> is shared across multiple threads.
EVP_RAND_get_params() retrieves details about the implementation
I<rand>.