Re: [PATCH 2/3] random: check for crng_init == 0, not crng_ready() in add_device_randomness()

From: Eric Biggers
Date: Mon Feb 21 2022 - 00:38:35 EST


On Sun, Feb 13, 2022 at 12:10:21AM +0100, Jason A. Donenfeld wrote:
> This has no real functional change, as crng_pre_init_inject() (and
> before that, crng_slow_init()) always checks for == 0, not >= 2. So
> correct the outer unlocked change to reflect that.
>
> Cc: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>
> Cc: Theodore Ts'o <tytso@xxxxxxx>
> Signed-off-by: Jason A. Donenfeld <Jason@xxxxxxxxx>
> ---
> drivers/char/random.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/random.c b/drivers/char/random.c
> index a128bb947bd4..9a8e1bb9845d 100644
> --- a/drivers/char/random.c
> +++ b/drivers/char/random.c
> @@ -1007,7 +1007,7 @@ void add_device_randomness(const void *buf, size_t size)
> unsigned long time = random_get_entropy() ^ jiffies;
> unsigned long flags;
>
> - if (!crng_ready() && size)
> + if (crng_init == 0 && size)
> crng_pre_init_inject(buf, size, false, false);
>
> spin_lock_irqsave(&input_pool.lock, flags);
> --
> 2.35.0
>

Reviewed-by: Eric Biggers <ebiggers@xxxxxxxxxx>

- Eric