[openssl/openssl] 7f2c22: Avoid taking a write lock in RAND_get_rand_method()

Matt Caswell noreply at github.com
Tue May 30 16:27:03 UTC 2023


  Branch: refs/heads/master
  Home:   https://github.com/openssl/openssl
  Commit: 7f2c22c1b9ec46070aa588d7f4a5ad5fe4a60bf4
      https://github.com/openssl/openssl/commit/7f2c22c1b9ec46070aa588d7f4a5ad5fe4a60bf4
  Author: Matt Caswell <matt at openssl.org>
  Date:   2023-05-30 (Tue, 30 May 2023)

  Changed paths:
    M crypto/rand/rand_lib.c

  Log Message:
  -----------
  Avoid taking a write lock in RAND_get_rand_method()

The function RAND_get_rand_method() is called every time RAND_bytes() or
RAND_priv_bytes() is called. We were obtaining a write lock in order to
find the default random method - even though we rarely write. We change
this to a read lock and only fallback to a write lock if we need to.

Partial fix for #20286

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Paul Dale <pauli at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20929)




More information about the openssl-commits mailing list