]> git.ipfire.org Git - thirdparty/openssl.git/commit
Fix corruption when searching for CRLs in hashed directories (1.1)
authorHugo Landau <hlandau@openssl.org>
Wed, 18 Jan 2023 15:43:56 +0000 (15:43 +0000)
committerHugo Landau <hlandau@openssl.org>
Tue, 24 Jan 2023 14:45:50 +0000 (14:45 +0000)
commit44da71693cdad2deb6430a47d3f3ee9f57065091
treec3ea8b090768d4c0897abf6194f217cfe660f7ee
parentadc3cfe452daa0fe51b8059929b2dafdc42737e4
Fix corruption when searching for CRLs in hashed directories (1.1)

The by_dir certificate/CRL lookup code uses an OPENSSL_STACK to track
how many sequentially numbered CRL files have been loaded for a given
X509_NAME hash which is being requested. This avoids loading already
loaded CRL files and repeated stat() calls.

This OPENSSL_STACK is searched using sk_find, however this mutates
the OPENSSL_STACK unless it is known to be sorted. This operation
therefore requires a write lock, which was not taken.

Fix this issue by sorting the OPENSSL_STACK whenever it is mutated. This
guarantees no mutation will occur during sk_find. This is chosen over
taking a write lock during sk_find as retrieving a CRL by X509_NAME is
assumed to be a hotter path than the case where a new CRL is installed.

Also optimise the code by avoiding creating the structure to track the
last CRL file sequence number in the circumstance where it would match
the initial value, namely where no CRL with the given hash is installed.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20127)
crypto/x509/by_dir.c