diff options
author | Matt Caswell <matt@openssl.org> | 2021-02-19 17:03:43 +0000 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-02-25 08:37:22 +1000 |
commit | d84f5515faf3fe00ed5eeca7e7b8b041be863e90 (patch) | |
tree | b2e8245e0a152f16b5bb2c5260e47781a6261c9d /crypto/store/store_meth.c | |
parent | 6be27456e1346121b1fed797e92353733b59e16e (diff) | |
download | openssl-new-d84f5515faf3fe00ed5eeca7e7b8b041be863e90.tar.gz |
Don't hold a lock when calling a callback in ossl_namemap_doall_names
We don't want to hold a read lock when calling a user supplied callback.
That callback could do anything so the risk of a deadlock is high.
Instead we collect all the names first inside the read lock, and then
subsequently call the user callback outside the read lock.
Fixes #14225
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14250)
Diffstat (limited to 'crypto/store/store_meth.c')
-rw-r--r-- | crypto/store/store_meth.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crypto/store/store_meth.c b/crypto/store/store_meth.c index d66b30f0ad..04f7249ddc 100644 --- a/crypto/store/store_meth.c +++ b/crypto/store/store_meth.c @@ -452,17 +452,19 @@ void OSSL_STORE_LOADER_do_all_provided(OSSL_LIB_CTX *libctx, &data); } -void OSSL_STORE_LOADER_names_do_all(const OSSL_STORE_LOADER *loader, - void (*fn)(const char *name, void *data), - void *data) +int OSSL_STORE_LOADER_names_do_all(const OSSL_STORE_LOADER *loader, + void (*fn)(const char *name, void *data), + void *data) { if (loader == NULL) - return; + return 0; if (loader->prov != NULL) { OSSL_LIB_CTX *libctx = ossl_provider_libctx(loader->prov); OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx); - ossl_namemap_doall_names(namemap, loader->scheme_id, fn, data); + return ossl_namemap_doall_names(namemap, loader->scheme_id, fn, data); } + + return 1; } |