public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/openssl] rawhide: Do not advertise OPENSSL_INIT_LOAD_CONFIG in optsdone too soon
@ 2026-09-09  9:28 
  0 siblings, 0 replies; only message in thread
From:  @ 2026-09-09  9:28 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/openssl
            Branch : rawhide
            Commit : d3b0fa5705341e3230f3e6f6c8eb3c87bffd32f4
            Author : Pavol Žáčik <pzacik@redhat.com>
            Date   : 2026-09-09T10:57:42+02:00
            Stats  : +70/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/openssl/c/d3b0fa5705341e3230f3e6f6c8eb3c87bffd32f4?branch=rawhide

            Log:
            Do not advertise OPENSSL_INIT_LOAD_CONFIG in optsdone too soon

Relates: rhbz#2524692

---
diff --git a/0017-Dont-advertise-config-loading-as-done-soon.patch b/0017-Dont-advertise-config-loading-as-done-soon.patch
new file mode 100644
index 0000000..fed34d0
--- /dev/null
+++ b/0017-Dont-advertise-config-loading-as-done-soon.patch
@@ -0,0 +1,62 @@
+From d115fd05e3986e90db18776ad49103fadccbe52f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= <zacik.pa@gmail.com>
+Date: Wed, 2 Sep 2026 14:54:28 +0200
+Subject: [PATCH] Do not advertise OPENSSL_INIT_LOAD_CONFIG in optsdone too
+ soon
+
+If there was no explicit call to OPENSSL_init_crypto before starting
+threading, it would result in a race between loading the config in
+one thread, and attempting to use features dependent on the config,
+e.g., providers in other threads.
+
+The first thread that gets into OPENSSL_init_crypto would start loading
+the config and set `loading` to 1 The same thread may re-enter the function
+recursively and should do nothing, but it would actually update `optsdone`
+with OPENSSL_INIT_LOAD_CONFIG, even though the loading has not finished yet.
+This commit fixes the issue by masking the opts bit out if we re-enter
+OPENSSL_init_crypto.
+
+Assisted-by: Claude:claude-opus-4.8
+---
+ crypto/init.c | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/crypto/init.c b/crypto/init.c
+index 302e37f7fae33..1863894b39343 100644
+--- a/crypto/init.c
++++ b/crypto/init.c
+@@ -348,6 +348,7 @@ void ossl_cleanup_destructor(void)
+ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
+ {
+     uint64_t tmp;
++    uint64_t optsdone_bits = opts;
+     int aloaddone = 0;
+ 
+     /* Applications depend on 0 being returned when cleanup was already done */
+@@ -453,8 +454,15 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
+     if (opts & OPENSSL_INIT_LOAD_CONFIG) {
+         int loading = CRYPTO_THREAD_get_local(&in_init_config_local) != NULL;
+ 
+-        /* If called recursively from OBJ_ calls, just skip it. */
+-        if (!loading) {
++        /* If called recursively from OBJ_ calls during config loading,
++         * we have to mask OPENSSL_INIT_LOAD_CONFIG in optsdone to not
++         * advertise that config loading is complete, otherwise other
++         * threads may proceed, e.g., to fetching from a provider that
++         * is not yet loaded.
++         */
++        if (loading) {
++            optsdone_bits &= ~(uint64_t)OPENSSL_INIT_LOAD_CONFIG;
++        } else {
+             int ret;
+ 
+             if (!CRYPTO_THREAD_set_local(&in_init_config_local, (void *)-1))
+@@ -480,7 +488,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
+         && !RUN_ONCE(&async, ossl_init_async))
+         return 0;
+ 
+-    if (!CRYPTO_atomic_or(&optsdone, opts, &tmp, optsdone_lock))
++    if (!CRYPTO_atomic_or(&optsdone, optsdone_bits, &tmp, optsdone_lock))
+         return 0;
+ 
+     return 1;

diff --git a/openssl.spec b/openssl.spec
index e27a56f..5529912 100644
--- a/openssl.spec
+++ b/openssl.spec
@@ -30,7 +30,7 @@ print(string.sub(hash, 0, 16))
 Summary: Utilities from the general purpose cryptography library with TLS implementation
 Name: openssl
 Version: 4.0.2
-Release: 2%{?dist}
+Release: 3%{?dist}
 Epoch: 1
 Source0: openssl-%{version}.tar.gz
 Source4: openssl.rpmlintrc
@@ -53,6 +53,8 @@ Patch0013: 0013-FIPS-PKCS12-PBMAC1-defaults.patch
 Patch0014: 0014-FIPS-EC-disable-weak-curves.patch
 Patch0015: 0015-Make-openssl-speed-run-in-FIPS-mode.patch
 Patch0016: 0016-Allow-hybrid-MLKEM-in-FIPS-mode.patch
+# https://github.com/openssl/openssl/commit/457c55324724f385e968eeee00955b8b1bec8910
+Patch0017: 0017-Dont-advertise-config-loading-as-done-soon.patch
 
 License: Apache-2.0
 URL: http://www.openssl.org/
@@ -376,6 +378,11 @@ ln -s /etc/crypto-policies/back-ends/openssl_fips.config $RPM_BUILD_ROOT%{_sysco
 %ldconfig_scriptlets libs
 
 %changelog
+* Wed Sep 09 2026 Pavol Žáčik <pzacik@redhat.com> - 1:4.0.2-3
+- Do not advertise OPENSSL_INIT_LOAD_CONFIG in optsdone too soon
+  (Backport https://github.com/openssl/openssl/pull/32646)
+  Relates: rhbz#2524692
+
 * Tue Sep 08 2026 Dmitry Belyavskiy <dbelyavs@redhat.com> - 1:4.0.2-2
 - Obsolete openssl-devel-engine explicitly
   Resolves: rhbz#2527847

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-09  9:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09  9:28 [rpms/openssl] rawhide: Do not advertise OPENSSL_INIT_LOAD_CONFIG in optsdone too soon 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox