]> git.ipfire.org Git - thirdparty/openssl.git/commit
read lock store on ossl_method_store_do_all
authorNeil Horman <nhorman@openssl.org>
Tue, 2 Jul 2024 18:27:42 +0000 (14:27 -0400)
committerTomas Mraz <tomas@openssl.org>
Tue, 9 Jul 2024 09:27:53 +0000 (11:27 +0200)
commitd8def79838cd0d5e7c21d217aa26edb5229f0ab4
tree1d91b50ccc340d2c2234b2ff541adde00dac6bbe
parent97bfbb98b0f9f2a381a47a01ae4e20f511adae05
read lock store on ossl_method_store_do_all

Theres a data race between ossl_method_store_insert and
ossl_method_store_do_all, as the latter doesn't take the property lock
before iterating.

However, we can't lock in do_all, as the call stack in several cases
later attempts to take the write lock.

The choices to fix it are I think:
1) add an argument to indicate to ossl_method_store_do_all weather to
   take the read or write lock when doing iterations, and add an
   is_locked api to the ossl_property_[read|write] lock family so that
   subsequent callers can determine if they need to take a lock or not

2) Clone the algs sparse array in ossl_method_store_do_all and use the
   clone to iterate with no lock held, ensuring that updates to the
   parent copy of the sparse array are left untoucheTheres a data race
   between ossl_method_store_insert and ossl_method_store_do_all, as the
   latter doesn't take the property lock before iterating.

I think method (2), while being a bit more expensive, is probably the
far less invasive way to go here

Fixes #24672

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24782)
crypto/property/property.c