* [PATCH] random: remove use_input_pool parameter from crng_reseed()
@ 2022-02-04 22:17 Eric Biggers
2022-02-04 22:56 ` Jason A. Donenfeld
2022-02-05 7:22 ` Dominik Brodowski
0 siblings, 2 replies; 3+ messages in thread
From: Eric Biggers @ 2022-02-04 22:17 UTC (permalink / raw)
To: Jason A . Donenfeld , Theodore Ts'o; +Cc: linux-crypto, linux-kernel
From: Eric Biggers <ebiggers@google.com>
The primary_crng is always reseeded from the input_pool, while the NUMA
crngs are always reseeded from the primary_crng. Remove the redundant
'use_input_pool' parameter from crng_reseed() and just directly check
whether the crng is the primary_crng.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
drivers/char/random.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index e16cf254db15..964bce981235 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -371,7 +371,7 @@ static struct {
static void extract_entropy(void *buf, size_t nbytes);
-static void crng_reseed(struct crng_state *crng, bool use_input_pool);
+static void crng_reseed(struct crng_state *crng);
/*
* This function adds bytes into the entropy "pool". It does not
@@ -470,7 +470,7 @@ static void credit_entropy_bits(int nbits)
trace_credit_entropy_bits(nbits, entropy_count, _RET_IP_);
if (crng_init < 2 && entropy_count >= POOL_MIN_BITS)
- crng_reseed(&primary_crng, true);
+ crng_reseed(&primary_crng);
}
/*********************************************************************
@@ -707,7 +707,7 @@ static int crng_slow_load(const u8 *cp, size_t len)
return 1;
}
-static void crng_reseed(struct crng_state *crng, bool use_input_pool)
+static void crng_reseed(struct crng_state *crng)
{
unsigned long flags;
int i;
@@ -716,7 +716,7 @@ static void crng_reseed(struct crng_state *crng, bool use_input_pool)
u32 key[8];
} buf;
- if (use_input_pool) {
+ if (crng == &primary_crng) {
int entropy_count;
do {
entropy_count = READ_ONCE(input_pool.entropy_count);
@@ -756,7 +756,7 @@ static void _extract_crng(struct crng_state *crng, u8 out[CHACHA_BLOCK_SIZE])
init_time = READ_ONCE(crng->init_time);
if (time_after(READ_ONCE(crng_global_init_time), init_time) ||
time_after(jiffies, init_time + CRNG_RESEED_INTERVAL))
- crng_reseed(crng, crng == &primary_crng);
+ crng_reseed(crng);
}
spin_lock_irqsave(&crng->lock, flags);
chacha20_block(&crng->state[0], out);
@@ -1555,7 +1555,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
return -EPERM;
if (crng_init < 2)
return -ENODATA;
- crng_reseed(&primary_crng, true);
+ crng_reseed(&primary_crng);
WRITE_ONCE(crng_global_init_time, jiffies - 1);
return 0;
default:
base-commit: 4bccade22d405309cbc588094f956f4d310e4677
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] random: remove use_input_pool parameter from crng_reseed()
2022-02-04 22:17 [PATCH] random: remove use_input_pool parameter from crng_reseed() Eric Biggers
@ 2022-02-04 22:56 ` Jason A. Donenfeld
2022-02-05 7:22 ` Dominik Brodowski
1 sibling, 0 replies; 3+ messages in thread
From: Jason A. Donenfeld @ 2022-02-04 22:56 UTC (permalink / raw)
To: Eric Biggers; +Cc: Theodore Ts'o, Linux Crypto Mailing List, LKML
Hey Eric,
On Fri, Feb 4, 2022 at 11:18 PM Eric Biggers <ebiggers@kernel.org> wrote:
> The primary_crng is always reseeded from the input_pool, while the NUMA
> crngs are always reseeded from the primary_crng. Remove the redundant
> 'use_input_pool' parameter from crng_reseed() and just directly check
> whether the crng is the primary_crng.
Nice simplification, thanks.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] random: remove use_input_pool parameter from crng_reseed()
2022-02-04 22:17 [PATCH] random: remove use_input_pool parameter from crng_reseed() Eric Biggers
2022-02-04 22:56 ` Jason A. Donenfeld
@ 2022-02-05 7:22 ` Dominik Brodowski
1 sibling, 0 replies; 3+ messages in thread
From: Dominik Brodowski @ 2022-02-05 7:22 UTC (permalink / raw)
To: Eric Biggers
Cc: Jason A . Donenfeld , Theodore Ts'o, linux-crypto,
linux-kernel
Am Fri, Feb 04, 2022 at 02:17:33PM -0800 schrieb Eric Biggers:
> From: Eric Biggers <ebiggers@google.com>
>
> The primary_crng is always reseeded from the input_pool, while the NUMA
> crngs are always reseeded from the primary_crng. Remove the redundant
> 'use_input_pool' parameter from crng_reseed() and just directly check
> whether the crng is the primary_crng.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
Thanks,
Dominik
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-05 8:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-04 22:17 [PATCH] random: remove use_input_pool parameter from crng_reseed() Eric Biggers
2022-02-04 22:56 ` Jason A. Donenfeld
2022-02-05 7:22 ` Dominik Brodowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox