openssl/openssl
TSAN: data race in ossl_default_provider_init in openssl 3.5.4
已關閉
#28,935 建立於 2025年10月16日
branch: 3.0branch: 3.3branch: 3.4branch: 3.5branch: 3.6branch: 4.0branch: masterhelp wantedtriaged: bug
倉庫指標
- 星標
- (30,157 顆星)
- PR 合併指標
- (30 天內沒有已合併 PR)
描述
OpenSSL 3.5.4 built with -fsanitize=thread.
It looks like ossl_default_provider_init always overwrites the global c_get_params and c_gettable_params. This leads to a data race when OSSL_PROVIDER_load is called by different threads.
I'm not sure if those could be changed to be local variables instead?
The reason my application calls OSSL_PROVIDER_load on different threads is that it uses a different OSSL_LIB_CTX per thread to reduce contention, and OSSL_PROVIDER_load is used to load the "default" provider into each context.
WARNING: ThreadSanitizer: data race (pid=1810)
Write of size 8 at 0x7ff0d5f0a540 by thread T3:
#0 ossl_default_provider_init openssl-3.5.4/providers/defltprov.c:737:31 (libcrypto.so.3+0x5b7450)
#1 provider_init openssl-3.5.4/crypto/provider_core.c:1045:10 (libcrypto.so.3+0x3ea936)
#2 provider_activate openssl-3.5.4/crypto/provider_core.c:1271:14 (libcrypto.so.3+0x3ea936)
#3 ossl_provider_activate openssl-3.5.4/crypto/provider_core.c:1412:18 (libcrypto.so.3+0x3ea552)
#4 OSSL_PROVIDER_try_load_ex openssl-3.5.4/crypto/provider.c:31:10 (libcrypto.so.3+0x3e6c4e)
#5 OSSL_PROVIDER_load_ex openssl-3.5.4/crypto/provider.c:62:16 (libcrypto.so.3+0x3e6dc0)
#6 OSSL_PROVIDER_load openssl-3.5.4/crypto/provider.c:68:12 (libcrypto.so.3+0x3e6dc0)
...
Previous write of size 8 at 0x7ff0d5f0a540 by thread T2:
#0 ossl_default_provider_init openssl-3.5.4/providers/defltprov.c:737:31 (libcrypto.so.3+0x5b7450)
#1 provider_init openssl-3.5.4/crypto/provider_core.c:1045:10 (libcrypto.so.3+0x3ea936)
#2 provider_activate openssl-3.5.4/crypto/provider_core.c:1271:14 (libcrypto.so.3+0x3ea936)
#3 ossl_provider_activate openssl-3.5.4/crypto/provider_core.c:1412:18 (libcrypto.so.3+0x3ea552)
#4 OSSL_PROVIDER_try_load_ex openssl-3.5.4/crypto/provider.c:31:10 (libcrypto.so.3+0x3e6c4e)
#5 OSSL_PROVIDER_load_ex openssl-3.5.4/crypto/provider.c:62:16 (libcrypto.so.3+0x3e6dc0)
#6 OSSL_PROVIDER_load openssl-3.5.4/crypto/provider.c:68:12 (libcrypto.so.3+0x3e6dc0)
...