[openssl/openssl] e31d75: rand: factor out seed source creation and fix stor...

"'Jakub Zelenka' via openssl-commits" <[email protected]> Mon, 27 Jul 2026 02:14:37 -0700
Newsgroups gmane.comp.encryption.openssl.cvs
Message-ID <openssl/openssl/push/refs/heads/openssl-4.0/[email protected]>
  Branch: refs/heads/openssl-4.0
  Home:   https://github.com/openssl/openssl
  Commit: e31d75713e0772b7264c0d73958ab4dfbb83250c
      https://github.com/openssl/openssl/commit/e31d75713e0772b7264c0d73958ab4dfbb83250c
  Author: Jakub Zelenka <[email protected]>
  Date:   2026-07-27 (Mon, 27 Jul 2026)

  Changed paths:
    M crypto/rand/rand_lib.c
    M test/rand_test.c

  Log Message:
  -----------
  rand: factor out seed source creation and fix store race

rand_get0_primary() created the seed source ahead of the primary DRBG
and stored both under the write lock at the end.  When two threads
raced to create the primary DRBG and one of them failed after having
created and stored the seed source, the other thread overwrote the
stored seed source with its own instance, leaking the previous one.

Factor the get-or-create logic out into rand_get0_seed() which
rechecks the global under the write lock, so exactly one instance is
kept and returned to every racing thread, and the seed source is
stored independently of the primary DRBG creation outcome.

Add a regression test checking that creating the primary DRBG creates
and stores the seed source and that later use keeps returning the same
instance.

Assisted-by: Claude:claude-fable-5

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Ryan Hooper <[email protected]>
MergeDate: Mon Jul 27 09:13:25 2026
(Merged from https://github.com/openssl/openssl/pull/32029)



To unsubscribe from these emails, change your notification settings at https://github.com/openssl/openssl/settings/notifications

-- 
You received this message because you are subscribed to the Google Groups "openssl-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/a/openssl.org/d/msgid/openssl-commits/openssl/openssl/push/refs/heads/openssl-4.0/758b11-e31d75%40github.com.