[openssl] master update

Dr. Paul Dale pauli at openssl.org
Wed Apr 7 13:28:37 UTC 2021


The branch master has been updated
       via  44e82b813fbec93664fa355a65024a56f6eb82d7 (commit)
       via  0bc27f7203258f662a533574d0c6c55fb08166eb (commit)
      from  bec9289143c955b330a8f9ad32f26f3da76e2685 (commit)


- Log -----------------------------------------------------------------
commit 44e82b813fbec93664fa355a65024a56f6eb82d7
Author: Pauli <pauli at openssl.org>
Date:   Tue Apr 6 12:25:58 2021 +1000

    Remove locking in CRYPTO_secure_allocated()
    
    The check for being in secure memory is against the arena.  The arena is only
    ever modified by sh_init() and sh_done() and in both cases, it is done without
    locking.  Thus, it is safe for the CRYPTO_secure_allocated() to not lock.
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14775)

commit 0bc27f7203258f662a533574d0c6c55fb08166eb
Author: Pauli <pauli at openssl.org>
Date:   Tue Apr 6 12:24:06 2021 +1000

    Make the lock in CRYPTO_secure_allocated() a read lock
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14775)

-----------------------------------------------------------------------

Summary of changes:
 crypto/mem_sec.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c
index ebc0e557b5..86ff41bf87 100644
--- a/crypto/mem_sec.c
+++ b/crypto/mem_sec.c
@@ -208,15 +208,14 @@ void CRYPTO_secure_clear_free(void *ptr, size_t num,
 int CRYPTO_secure_allocated(const void *ptr)
 {
 #ifndef OPENSSL_NO_SECURE_MEMORY
-    int ret;
-
     if (!secure_mem_initialized)
         return 0;
-    if (!CRYPTO_THREAD_write_lock(sec_malloc_lock))
-        return 0;
-    ret = sh_allocated(ptr);
-    CRYPTO_THREAD_unlock(sec_malloc_lock);
-    return ret;
+    /*
+     * Only read accesses to the arena take place in sh_allocated() and this
+     * is only changed by the sh_init() and sh_done() calls which are not
+     * locked.  Hence, it is safe to make this check without a lock too.
+     */
+    return sh_allocated(ptr);
 #else
     return 0;
 #endif /* OPENSSL_NO_SECURE_MEMORY */


More information about the openssl-commits mailing list