From: Jason A. Donenfeld Date: Sat, 12 Feb 2022 00:26:17 +0000 (+0100) Subject: random: do not take pool spinlock at boot X-Git-Tag: v4.14.285~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58e0c4ff5342e1962a7464d18568a55a0fc26c9f;p=thirdparty%2Fkernel%2Fstable.git random: do not take pool spinlock at boot commit afba0b80b977b2a8f16234f2acd982f82710ba33 upstream. Since rand_initialize() is run while interrupts are still off and nothing else is running, we don't need to repeatedly take and release the pool spinlock, especially in the RDSEED loop. Reviewed-by: Eric Biggers Reviewed-by: Dominik Brodowski Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/char/random.c b/drivers/char/random.c index 81705b0230b85..0f612c854fc41 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -973,10 +973,10 @@ int __init rand_initialize(void) rv = random_get_entropy(); arch_init = false; } - mix_pool_bytes(&rv, sizeof(rv)); + _mix_pool_bytes(&rv, sizeof(rv)); } - mix_pool_bytes(&now, sizeof(now)); - mix_pool_bytes(utsname(), sizeof(*(utsname()))); + _mix_pool_bytes(&now, sizeof(now)); + _mix_pool_bytes(utsname(), sizeof(*(utsname()))); extract_entropy(base_crng.key, sizeof(base_crng.key)); ++base_crng.generation;