random: fix locking for crng_init in crng_reseed()
authorDominik Brodowski <linux@dominikbrodowski.net>
Wed, 9 Feb 2022 18:57:06 +0000 (19:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 May 2022 07:27:05 +0000 (09:27 +0200)
commit432b6e6e60093ebeec6a3972a2fce1412418b6c8
tree1905fae551cbff14a3f77a45b33bfd290f55cd01
parent06460c438d4aba1a5c8c3bb3164df60c91ea2586
random: fix locking for crng_init in crng_reseed()

commit 7191c628fe07b70d3f37de736d173d1b115396ed upstream.

crng_init is protected by primary_crng->lock. Therefore, we need
to hold this lock when increasing crng_init to 2. As we shouldn't
hold this lock for too long, only hold it for those parts which
require protection.

Signed-off-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>
drivers/char/random.c