]> git.ipfire.org Git - thirdparty/openssl.git/commit
Don't keep the store open in by_store_ctrl_ex
authorMatt Caswell <matt@openssl.org>
Thu, 7 Aug 2025 16:50:17 +0000 (17:50 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 4 Sep 2025 12:25:43 +0000 (13:25 +0100)
commitc0d968f0ac56ad507ab0101e537e7d530e9f0448
treed86006ccc93b447b5ba28933cd415be02c523e17
parent89ce0ef97ef85b4f0b8069ee51a79632320670c9
Don't keep the store open in by_store_ctrl_ex

Previously #27529 made a change to `by_store_ctrl_ex` in order to open
the OSSL_STORE early. The reason given in that PR is:

"This way, we can call OSSL_STORE_open_ex() in by_store_ctrl_ex(), and
get to see possible errors when the URI is loaded"

That PR then kept the store open until cache_objects is called and then
reused it. Unfortunately by the time cache_objects() is called we could be
in a multi-threaded scenario where the X509_STORE is being shared by
multiple threads. We then get a race condition where multiple threads are
all using (and ultimately closing) the same `OSSL_STORE_CTX`.

The purpose of keeping the `OSSL_STORE` object between by_store_ctrl_ex()
and `cache_objects` is presumably an optimisation to avoid having to open
the store twice. But this does not work because of the above issue.

We just take the hit and open it again.

Fixes #28171

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28385)
crypto/x509/by_store.c