Restore clearing of init_lock after free
authorBenjamin Kaduk <bkaduk@akamai.com>
Fri, 26 Jan 2018 15:32:40 +0000 (09:32 -0600)
committerBen Kaduk <kaduk@mit.edu>
Wed, 31 Jan 2018 18:25:28 +0000 (12:25 -0600)
The behavior of resetting the init_lock value to NULL after
freeing it during OPENSSL_cleanup() was added as part of the
global lock commits that were just reverted, but there is desire
to retain this behavior for clarity.

It is unclear that the library would actually remain usable in
any form after OPENSSL_cleanup(), since the required re-initialization
occurs under a CRYPTO_ONCE check that cannot be reset at cleanup time.
That said, a NULL dereference is probably more friendly behavior
in these treacherous waters than using freed memory would be.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5089)

crypto/init.c

index 71accaa2ca600598cb4cfc3588c8e38a1fa3a1cf..1b94d07e0465a3216dfcf67b0d796ba32ca8545f 100644 (file)
@@ -421,6 +421,7 @@ 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