diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-05-05 02:20:22 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-06-25 11:46:38 +0200 |
commit | 4798c86f1b70e391acddc532bbac0a243e014c4c (patch) | |
tree | 311b0fbcf69dfb0cd3ad146c2accf86943a71a06 /init | |
parent | 70e65f65f248961d573905a5cf6c88c5983681aa (diff) | |
download | linux-stable-4798c86f1b70e391acddc532bbac0a243e014c4c.tar.gz linux-stable-4798c86f1b70e391acddc532bbac0a243e014c4c.tar.bz2 linux-stable-4798c86f1b70e391acddc532bbac0a243e014c4c.zip |
init: call time_init() before rand_initialize()
commit fe222a6ca2d53c38433cba5d3be62a39099e708e upstream.
Currently time_init() is called after rand_initialize(), but
rand_initialize() makes use of the timer on various platforms, and
sometimes this timer needs to be initialized by time_init() first. In
order for random_get_entropy() to not return zero during early boot when
it's potentially used as an entropy source, reverse the order of these
two calls. The block doing random initialization was right before
time_init() before, so changing the order shouldn't have any complicated
effects.
Cc: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Stafford Horne <shorne@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'init')
-rw-r--r-- | init/main.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/init/main.c b/init/main.c index 6c2c39b3cccd..cb18c6d7b552 100644 --- a/init/main.c +++ b/init/main.c @@ -607,11 +607,13 @@ asmlinkage __visible void __init start_kernel(void) hrtimers_init(); softirq_init(); timekeeping_init(); + time_init(); /* * For best initial stack canary entropy, prepare it after: * - setup_arch() for any UEFI RNG entropy and boot cmdline access * - timekeeping_init() for ktime entropy used in rand_initialize() + * - time_init() for making random_get_entropy() work on some platforms * - rand_initialize() to get any arch-specific entropy like RDRAND * - add_latent_entropy() to get any latent entropy * - adding command line entropy @@ -621,7 +623,6 @@ asmlinkage __visible void __init start_kernel(void) add_device_randomness(command_line, strlen(command_line)); boot_init_stack_canary(); - time_init(); sched_clock_postinit(); printk_safe_init(); perf_event_init(); |