diff options
-rw-r--r-- | crypto/bio/b_addr.c | 2 | ||||
-rw-r--r-- | crypto/bio/bio_meth.c | 2 | ||||
-rw-r--r-- | crypto/engine/eng_lib.c | 2 | ||||
-rw-r--r-- | crypto/err/err.c | 2 | ||||
-rw-r--r-- | crypto/ex_data.c | 2 | ||||
-rw-r--r-- | crypto/init.c | 82 | ||||
-rw-r--r-- | crypto/mem_dbg.c | 9 | ||||
-rw-r--r-- | crypto/mem_sec.c | 2 | ||||
-rw-r--r-- | crypto/objects/o_names.c | 2 | ||||
-rw-r--r-- | crypto/rand/drbg_lib.c | 18 | ||||
-rw-r--r-- | crypto/rand/rand_lib.c | 4 | ||||
-rw-r--r-- | crypto/store/store_register.c | 2 | ||||
-rw-r--r-- | include/openssl/crypto.h | 1 | ||||
-rw-r--r-- | util/libcrypto.num | 1 |
14 files changed, 21 insertions, 110 deletions
diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c index 6fb135a758..ab8e7ffd95 100644 --- a/crypto/bio/b_addr.c +++ b/crypto/bio/b_addr.c @@ -603,7 +603,7 @@ static int addrinfo_wrap(int family, int socktype, DEFINE_RUN_ONCE_STATIC(do_bio_lookup_init) { OPENSSL_init_crypto(0, NULL); - bio_lookup_lock = CRYPTO_THREAD_glock_new("bio_lookup"); + bio_lookup_lock = CRYPTO_THREAD_lock_new(); return bio_lookup_lock != NULL; } diff --git a/crypto/bio/bio_meth.c b/crypto/bio/bio_meth.c index 955be84e41..1c5d196239 100644 --- a/crypto/bio/bio_meth.c +++ b/crypto/bio/bio_meth.c @@ -15,7 +15,7 @@ static CRYPTO_ONCE bio_type_init = CRYPTO_ONCE_STATIC_INIT; DEFINE_RUN_ONCE_STATIC(do_bio_type_init) { - bio_type_lock = CRYPTO_THREAD_glock_new("bio_type"); + bio_type_lock = CRYPTO_THREAD_lock_new(); return bio_type_lock != NULL; } diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c index 8f65584221..db7717fc8b 100644 --- a/crypto/engine/eng_lib.c +++ b/crypto/engine/eng_lib.c @@ -21,7 +21,7 @@ CRYPTO_ONCE engine_lock_init = CRYPTO_ONCE_STATIC_INIT; DEFINE_RUN_ONCE(do_engine_lock_init) { OPENSSL_init_crypto(0, NULL); - global_engine_lock = CRYPTO_THREAD_glock_new("global_engine"); + global_engine_lock = CRYPTO_THREAD_lock_new(); return global_engine_lock != NULL; } diff --git a/crypto/err/err.c b/crypto/err/err.c index c0bdbb8933..a83da9b0e0 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -266,7 +266,7 @@ static void ERR_STATE_free(ERR_STATE *s) DEFINE_RUN_ONCE_STATIC(do_err_strings_init) { OPENSSL_init_crypto(0, NULL); - err_string_lock = CRYPTO_THREAD_glock_new("err_string"); + err_string_lock = CRYPTO_THREAD_lock_new(); int_error_hash = lh_ERR_STRING_DATA_new(err_string_data_hash, err_string_data_cmp); return err_string_lock != NULL && int_error_hash != NULL; diff --git a/crypto/ex_data.c b/crypto/ex_data.c index 78162b5c09..538fdb1f1f 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -38,7 +38,7 @@ static CRYPTO_ONCE ex_data_init = CRYPTO_ONCE_STATIC_INIT; DEFINE_RUN_ONCE_STATIC(do_ex_data_init) { OPENSSL_init_crypto(0, NULL); - ex_data_lock = CRYPTO_THREAD_glock_new("ex_data"); + ex_data_lock = CRYPTO_THREAD_lock_new(); return ex_data_lock != NULL; } diff --git a/crypto/init.c b/crypto/init.c index 909775ab54..71accaa2ca 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -27,15 +27,6 @@ #include "internal/dso.h" #include "internal/store.h" - -typedef struct global_lock_st { - CRYPTO_RWLOCK *lock; - const char *name; - struct global_lock_st *next; -} GLOBAL_LOCK; - -static GLOBAL_LOCK *global_locks; - static int stopped = 0; static void ossl_init_thread_stop(struct thread_local_inits_st *locals); @@ -72,8 +63,6 @@ struct ossl_init_stop_st { OPENSSL_INIT_STOP *next; }; -static CRYPTO_RWLOCK *glock_lock = NULL; - static OPENSSL_INIT_STOP *stop_handlers = NULL; static CRYPTO_RWLOCK *init_lock = NULL; @@ -95,7 +84,6 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_base) #ifndef OPENSSL_SYS_UEFI atexit(OPENSSL_cleanup); #endif - /* Do not change this to glock's! */ if ((init_lock = CRYPTO_THREAD_lock_new()) == NULL) return 0; OPENSSL_cpuid_setup(); @@ -433,7 +421,6 @@ void OPENSSL_cleanup(void) stop_handlers = NULL; CRYPTO_THREAD_lock_free(init_lock); - init_lock = NULL; /* * We assume we are single-threaded for this function, i.e. no race @@ -514,16 +501,6 @@ void OPENSSL_cleanup(void) obj_cleanup_int(); err_cleanup(); - /* Free list of global locks. */ - while (global_locks != NULL) { - GLOBAL_LOCK *next = global_locks->next; - - free(global_locks); - global_locks = next; - } - CRYPTO_THREAD_lock_free(glock_lock); - glock_lock = NULL; - base_inited = 0; } @@ -707,56 +684,7 @@ int OPENSSL_atexit(void (*handler)(void)) return 1; } -#ifndef OPENSSL_SYS_UNIX -CRYPTO_RWLOCK *CRYPTO_THREAD_glock_new(const char *name) -{ - return CRYPTO_THREAD_lock_new(); -} - -#else -DEFINE_RUN_ONCE_STATIC(glock_init) -{ - glock_lock = CRYPTO_THREAD_lock_new(); - return glock_lock != NULL; -} - -/* - * Create a new global lock, return NULL on error. - */ -CRYPTO_RWLOCK *CRYPTO_THREAD_glock_new(const char *name) -{ - static CRYPTO_ONCE glock_once = CRYPTO_ONCE_STATIC_INIT; - GLOBAL_LOCK *newlock; - - if (glock_lock == NULL && !RUN_ONCE(&glock_once, glock_init)) - return NULL; - if ((newlock = malloc(sizeof(*newlock))) == NULL) - return NULL; - if ((newlock->lock = CRYPTO_THREAD_lock_new()) == NULL) { - free(newlock); - return NULL; - } - newlock->name = name; - CRYPTO_THREAD_write_lock(glock_lock); - newlock->next = global_locks; - global_locks = newlock; - CRYPTO_THREAD_unlock(glock_lock); - return newlock->lock; -} - -/* - * Unlock all global locks. - */ -static void unlock_all(void) -{ - GLOBAL_LOCK *lp; - - CRYPTO_THREAD_write_lock(glock_lock); - for (lp = global_locks; lp != NULL; lp = lp->next) - CRYPTO_THREAD_unlock(lp->lock); - CRYPTO_THREAD_unlock(glock_lock); -} - +#ifdef OPENSSL_SYS_UNIX /* * The following three functions are for OpenSSL developers. This is * where we set/reset state across fork (called via pthread_atfork when @@ -770,22 +698,14 @@ static void unlock_all(void) void OPENSSL_fork_prepare(void) { - GLOBAL_LOCK *lp; - - CRYPTO_THREAD_write_lock(glock_lock); - for (lp = global_locks; lp != NULL; lp = lp->next) - CRYPTO_THREAD_write_lock(lp->lock); - CRYPTO_THREAD_unlock(glock_lock); } void OPENSSL_fork_parent(void) { - unlock_all(); } void OPENSSL_fork_child(void) { - unlock_all(); rand_fork(); } #endif diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index b394de87ab..e11388224d 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -93,11 +93,10 @@ static CRYPTO_THREAD_ID disabling_threadid; DEFINE_RUN_ONCE_STATIC(do_memdbg_init) { - memdbg_lock = CRYPTO_THREAD_glock_new("malloc"); - long_memdbg_lock = CRYPTO_THREAD_glock_new("long_malloc"); - if (memdbg_lock == NULL - || long_memdbg_lock == NULL - || !CRYPTO_THREAD_init_local(&appinfokey, NULL)) { + memdbg_lock = CRYPTO_THREAD_lock_new(); + long_memdbg_lock = CRYPTO_THREAD_lock_new(); + if (memdbg_lock == NULL || long_memdbg_lock == NULL + || !CRYPTO_THREAD_init_local(&appinfokey, NULL)) { CRYPTO_THREAD_lock_free(memdbg_lock); memdbg_lock = NULL; CRYPTO_THREAD_lock_free(long_memdbg_lock); diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c index 8f4ae9c94a..4c01045495 100644 --- a/crypto/mem_sec.c +++ b/crypto/mem_sec.c @@ -68,7 +68,7 @@ int CRYPTO_secure_malloc_init(size_t size, int minsize) int ret = 0; if (!secure_mem_initialized) { - sec_malloc_lock = CRYPTO_THREAD_glock_new("sec_malloc"); + sec_malloc_lock = CRYPTO_THREAD_lock_new(); if (sec_malloc_lock == NULL) return 0; if ((ret = sh_init(size, minsize)) != 0) { diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index d0e8e05fe8..73676445c1 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -69,7 +69,7 @@ DEFINE_RUN_ONCE_STATIC(o_names_init) { CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE); names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp); - obj_lock = CRYPTO_THREAD_glock_new("obj"); + obj_lock = CRYPTO_THREAD_lock_new(); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE); return names_lh != NULL && obj_lock != NULL; } diff --git a/crypto/rand/drbg_lib.c b/crypto/rand/drbg_lib.c index 5e6bdceb1e..cb2f9e8d92 100644 --- a/crypto/rand/drbg_lib.c +++ b/crypto/rand/drbg_lib.c @@ -98,7 +98,7 @@ static const char ossl_pers_string[] = "OpenSSL NIST SP 800-90A DRBG"; static CRYPTO_ONCE rand_drbg_init = CRYPTO_ONCE_STATIC_INIT; -static RAND_DRBG *drbg_setup(const char *name, RAND_DRBG *parent); +static RAND_DRBG *drbg_setup(RAND_DRBG *parent); static void drbg_cleanup(RAND_DRBG *drbg); /* @@ -666,24 +666,18 @@ void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx) /* * Allocates a new global DRBG on the secure heap (if enabled) and * initializes it with default settings. - * A global lock for the DRBG is created with the given name. * * Returns a pointer to the new DRBG instance on success, NULL on failure. */ -static RAND_DRBG *drbg_setup(const char *name, RAND_DRBG *parent) +static RAND_DRBG *drbg_setup(RAND_DRBG *parent) { RAND_DRBG *drbg; - if (name == NULL) { - RANDerr(RAND_F_DRBG_SETUP, ERR_R_INTERNAL_ERROR); - return NULL; - } - drbg = OPENSSL_secure_zalloc(sizeof(RAND_DRBG)); if (drbg == NULL) return NULL; - drbg->lock = CRYPTO_THREAD_glock_new(name); + drbg->lock = CRYPTO_THREAD_lock_new(); if (drbg->lock == NULL) { RANDerr(RAND_F_DRBG_SETUP, RAND_R_FAILED_TO_CREATE_LOCK); goto err; @@ -737,9 +731,9 @@ DEFINE_RUN_ONCE_STATIC(do_rand_drbg_init) if (!OPENSSL_init_crypto(0, NULL)) return 0; - drbg_master = drbg_setup("drbg_master", NULL); - drbg_public = drbg_setup("drbg_public", drbg_master); - drbg_private = drbg_setup("drbg_private", drbg_master); + drbg_master = drbg_setup(NULL); + drbg_public = drbg_setup(drbg_master); + drbg_private = drbg_setup(drbg_master); if (drbg_master == NULL || drbg_public == NULL || drbg_private == NULL) return 0; diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index ab03356646..20ac5839e6 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -282,10 +282,10 @@ DEFINE_RUN_ONCE_STATIC(do_rand_init) int ret = 1; #ifndef OPENSSL_NO_ENGINE - rand_engine_lock = CRYPTO_THREAD_glock_new("rand_engine"); + rand_engine_lock = CRYPTO_THREAD_lock_new(); ret &= rand_engine_lock != NULL; #endif - rand_meth_lock = CRYPTO_THREAD_glock_new("rand_meth"); + rand_meth_lock = CRYPTO_THREAD_lock_new(); ret &= rand_meth_lock != NULL; return ret; diff --git a/crypto/store/store_register.c b/crypto/store/store_register.c index 987ca42f8c..85c38b84dd 100644 --- a/crypto/store/store_register.c +++ b/crypto/store/store_register.c @@ -20,7 +20,7 @@ static CRYPTO_ONCE registry_init = CRYPTO_ONCE_STATIC_INIT; DEFINE_RUN_ONCE_STATIC(do_registry_init) { - registry_lock = CRYPTO_THREAD_glock_new("registry"); + registry_lock = CRYPTO_THREAD_lock_new(); return registry_lock != NULL; } diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h index 5e9517d0fb..478f9e2843 100644 --- a/include/openssl/crypto.h +++ b/include/openssl/crypto.h @@ -67,7 +67,6 @@ typedef struct { typedef void CRYPTO_RWLOCK; CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void); -CRYPTO_RWLOCK *CRYPTO_THREAD_glock_new(const char *name); int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock); int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock); int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock); diff --git a/util/libcrypto.num b/util/libcrypto.num index 536a3d24ee..a2d03c602a 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -4388,7 +4388,6 @@ EVP_aria_256_ccm 4332 1_1_1 EXIST::FUNCTION:ARIA EVP_aria_128_gcm 4333 1_1_1 EXIST::FUNCTION:ARIA EVP_aria_128_ccm 4334 1_1_1 EXIST::FUNCTION:ARIA EVP_aria_192_gcm 4335 1_1_1 EXIST::FUNCTION:ARIA -CRYPTO_THREAD_glock_new 4336 1_1_1 EXIST::FUNCTION: UI_get_result_length 4337 1_1_1 EXIST::FUNCTION: UI_set_result_ex 4338 1_1_1 EXIST::FUNCTION: UI_get_result_string_length 4339 1_1_1 EXIST::FUNCTION: |