1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
From ae80106fb9d39513a2a8580008b4a8b2057498ed Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Thu, 23 Oct 2025 15:09:58 +0900
Subject: [PATCH 3/6] random:jent: Fix for jent_rng_is_initialized.
* random/rndjent.c (_gcry_rndjent_poll): Set jent_rng_is_initialized
after successful initialization.
(_gcry_rndjent_fini): Clear jent_rng_is_initialized.
--
Cherry-pick master commit of:
0ceca9993f5a94389624f6cf12e07165cd2391e4
Reported-by: Eric Berry <eric.berry@canonical.com>
---
random/rndjent.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/random/rndjent.c b/random/rndjent.c
index 0468c7cb..a6ad40f0 100644
--- a/random/rndjent.c
+++ b/random/rndjent.c
@@ -109,16 +109,16 @@
/* This is the lock we use to serialize access to this RNG. The extra
* integer variable is only used to check the locking state; that is,
* it is not meant to be thread-safe but merely as a failsafe feature
* to assert proper locking. */
GPGRT_LOCK_DEFINE (jent_rng_lock);
static int jent_rng_is_locked;
-/* This flag tracks whether the RNG has been initialized - either
- * with error or with success. Protected by JENT_RNG_LOCK. */
+/* This flag tracks whether the RNG has been initialized successfully.
+ * Protected by JENT_RNG_LOCK. */
static int jent_rng_is_initialized;
/* Our collector. The RNG is in a working state if its value is not
* NULL. Protected by JENT_RNG_LOCK. */
struct rand_data *jent_rng_collector;
/* The number of times the core entropy function has been called and
@@ -286,21 +286,24 @@ _gcry_rndjent_poll (void (*add)(const void*, size_t, enum random_origins),
if ( is_rng_available () )
{
lock_rng ();
if (!jent_rng_is_initialized)
{
/* Auto-initialize. */
- jent_rng_is_initialized = 1;
jent_entropy_collector_free (jent_rng_collector);
jent_rng_collector = NULL;
if ( !(_gcry_random_read_conf () & RANDOM_CONF_DISABLE_JENT))
{
if (!jent_entropy_init ())
- jent_rng_collector = jent_entropy_collector_alloc (1, 0);
+ {
+ jent_rng_collector = jent_entropy_collector_alloc (1, 0);
+ if (jent_rng_collector != NULL)
+ jent_rng_is_initialized = 1;
+ }
}
}
if (jent_rng_collector && add)
{
/* We have a working JENT and it has not been disabled. */
char buffer[32];
@@ -398,12 +401,13 @@ _gcry_rndjent_fini (void)
#ifdef USE_JENT
lock_rng ();
if (jent_rng_is_initialized)
{
jent_entropy_collector_free (jent_rng_collector);
jent_rng_collector = NULL;
+ jent_rng_is_initialized = 0;
}
unlock_rng ();
#endif
}
--
2.51.0
|