]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
random: only read from /dev/random after its pool has received 128 bits
authorTheodore Ts'o <tytso@mit.edu>
Wed, 20 Feb 2019 21:06:38 +0000 (16:06 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 09:46:26 +0000 (11:46 +0200)
commitfd5e41d61e3796f67877ec0b629fb423d8ec13a8
tree121459cc64fc585de4c8daa6a52748427e4c18bc
parent72ed3248d0d6693c5c3d5821a64df718bb9b02b1
random: only read from /dev/random after its pool has received 128 bits

commit eb9d1bf079bb438d1a066d72337092935fc770f6 upstream.

Immediately after boot, we allow reads from /dev/random before its
entropy pool has been fully initialized.  Fix this so that we don't
allow this until the blocking pool has received 128 bits.

We do this by repurposing the initialized flag in the entropy pool
struct, and use the initialized flag in the blocking pool to indicate
whether it is safe to pull from the blocking pool.

To do this, we needed to rework when we decide to push entropy from the
input pool to the blocking pool, since the initialized flag for the
input pool was used for this purpose.  To simplify things, we no
longer use the initialized flag for that purpose, nor do we use the
entropy_total field any more.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/random.c
include/trace/events/random.h