Commit ee7998c5 authored by Kees Cook's avatar Kees Cook Committed by Linus Torvalds

random: do not ignore early device randomness

The add_device_randomness() function would ignore incoming bytes if the
crng wasn't ready.  This additionally makes sure to make an early enough
call to add_latent_entropy() to influence the initial stack canary,
which is especially important on non-x86 systems where it stays the same
through the life of the boot.

Link: default avatarKees Cook <>
Cc: "Theodore Ts'o" <>
Cc: Arnd Bergmann <>
Cc: Greg Kroah-Hartman <>
Cc: Ingo Molnar <>
Cc: Jessica Yu <>
Cc: Steven Rostedt (VMware) <>
Cc: Viresh Kumar <>
Cc: Tejun Heo <>
Cc: Prarit Bhargava <>
Cc: Lokesh Vutla <>
Cc: Nicholas Piggin <>
Cc: AKASHI Takahiro <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 9380fa60
......@@ -987,6 +987,11 @@ void add_device_randomness(const void *buf, unsigned int size)
unsigned long time = random_get_entropy() ^ jiffies;
unsigned long flags;
if (!crng_ready()) {
crng_fast_load(buf, size);
trace_add_device_randomness(size, _RET_IP_);
spin_lock_irqsave(&input_pool.lock, flags);
_mix_pool_bytes(&input_pool, buf, size);
......@@ -518,6 +518,7 @@ asmlinkage __visible void __init start_kernel(void)
* Set up the initial canary ASAP:
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment