David Benjamin 08cecb4448 Add X509_STORE_get1_objects
X509_STORE_get0_objects returns a pointer to the X509_STORE's storage,
but this function is a bit deceptive. It is practically unusable in a
multi-threaded program. See, for example, RUSTSEC-2023-0072, a security
vulnerability caused by this OpenSSL API.

One might think that, if no other threads are mutating the X509_STORE,
it is safe to read the resulting list. However, the documention does not
mention that other logically-const operations on the X509_STORE, notably
certifcate verifications when a hash_dir is installed, will, under a
lock, write to the X509_STORE. The X509_STORE also internally re-sorts
the list on the first query.

If the caller knows to call X509_STORE_lock and X509_STORE_unlock, it
can work around this. But this is not obvious, and the documentation
does not discuss how X509_STORE_lock is very rarely safe to use. E.g.
one cannot call any APIs like X509_STORE_add_cert or
X509_STORE_CTX_get1_issuer while holding the lock because those
functions internally expect to take the lock. (X509_STORE_lock is
another such API which is not safe to export as public API.)

Rather than leave all this to the caller to figure out, the API should
have returned a shallow copy of the list, refcounting the values. Then
it could be internally locked and the caller can freely inspect the
result without synchronization with the X509_STORE.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23224)
2024-01-15 16:29:54 +01:00
..
2022-05-03 13:34:51 +01:00
2023-09-07 09:59:15 +01:00
2019-04-19 09:31:54 +01:00
2023-06-18 16:53:09 +10:00
2021-09-02 12:55:39 +10:00
2020-11-18 11:40:52 +01:00
2023-09-07 09:59:15 +01:00
2020-04-23 13:55:52 +01:00
2023-03-06 08:00:58 +11:00
2023-08-29 16:59:54 +02:00
2024-01-15 16:29:54 +01:00
2023-10-24 17:34:07 +01:00
2019-09-19 09:27:38 -04:00
2023-09-07 09:59:15 +01:00
2021-04-08 13:04:41 +01:00
2023-09-07 09:59:15 +01:00
2023-11-15 08:22:29 +01:00
2022-12-08 07:01:33 +01:00
2023-03-08 12:29:22 +01:00