The EFI stub executes only once after boot, and kexec'd kernels reuse the firmware context created on the first boot. This is intentional: we preserve as much of the original firmware provided context as we can, and pass it on unmodified, making kexec mostly idempotent. However, there is one piece of firmware context that we should not reuse, which is the EFI random seed, especially in cases where the kexec'ed kernel trusts the bootloader, and we declare the CRNG ready as soon as the firmware seed is mixed in. So in kexec capable kernels, we refresh the EFI random seed before passing it on. Currently, we refresh the seed without taking into account whether or not the RNG subsystem is fully initialized, which means we may end up passing on a seed that is weaker than desired. To avoid this, switch to get_random_bytes_wait(), which will wait for the CRNG init to complete. Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx> --- drivers/firmware/efi/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 860534bcfdac..7da49c783c01 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -1035,7 +1035,7 @@ static int update_efi_random_seed(struct notifier_block *nb, MEMREMAP_WB); if (seed != NULL) { seed->size = size; - get_random_bytes(seed->bits, seed->size); + get_random_bytes_wait(seed->bits, seed->size); memunmap(seed); } else { pr_err("Could not map UEFI random seed!\n"); -- 2.30.2