diff options
author | Pauli <pauli@openssl.org> | 2021-04-07 11:32:59 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-04-08 17:46:35 +1000 |
commit | 4b1f34f11ff94bc2d0169d6669bfc47f99bd93b3 (patch) | |
tree | 9fd4f62d675b6cf0d179ceb5256f367ab056f466 /crypto/context.c | |
parent | a135dea4e024ea6750be25859c1d613789a4d575 (diff) | |
download | openssl-4b1f34f11ff94bc2d0169d6669bfc47f99bd93b3.tar.gz |
property: lock the lib ctx when updating the property definition cache
Although the store being used is adequately and properly locked, the library
context is not. Due to the mechanisms used for fetching, it is possible for
multiple stores to live within the same library context for short periods.
This fix prevents threading issues resulting from such coincidences.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14773)
Diffstat (limited to 'crypto/context.c')
-rw-r--r-- | crypto/context.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/context.c b/crypto/context.c index 852f9dd7ce..6c088e6628 100644 --- a/crypto/context.c +++ b/crypto/context.c @@ -11,6 +11,7 @@ #include <openssl/conf.h> #include "internal/thread_once.h" #include "internal/property.h" +#include "internal/core.h" struct ossl_lib_ctx_onfree_list_st { ossl_lib_ctx_onfree_fn *fn; @@ -39,6 +40,21 @@ struct ossl_lib_ctx_st { struct ossl_lib_ctx_onfree_list_st *onfreelist; }; +int ossl_lib_ctx_write_lock(OSSL_LIB_CTX *ctx) +{ + return CRYPTO_THREAD_write_lock(ossl_lib_ctx_get_concrete(ctx)->lock); +} + +int ossl_lib_ctx_read_lock(OSSL_LIB_CTX *ctx) +{ + return CRYPTO_THREAD_read_lock(ossl_lib_ctx_get_concrete(ctx)->lock); +} + +int ossl_lib_ctx_unlock(OSSL_LIB_CTX *ctx) +{ + return CRYPTO_THREAD_unlock(ossl_lib_ctx_get_concrete(ctx)->lock); +} + static int context_init(OSSL_LIB_CTX *ctx) { size_t i; |