Skip to content

Commit

Permalink
random: check for crng_init == 0 in add_device_randomness()
Browse files Browse the repository at this point in the history
commit 1daf2f3 upstream.

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. Before this used
crng_ready(), which was not correct.

Cc: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
zx2c4 authored and gregkh committed May 30, 2022
1 parent 993d28d commit 0014e4f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,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);
Expand Down

0 comments on commit 0014e4f

Please sign in to comment.