aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2019-04-19 23:27:05 -0400
committerTheodore Ts'o <tytso@mit.edu>2019-04-19 23:27:05 -0400
commitd55535232c3dbde9a523a9d10d68670f5fe5dec3 (patch)
tree43265cdcfde71ed2fdbd562c17f034c28aab15bc /drivers/char/random.c
parenteb9d1bf079bb438d1a066d72337092935fc770f6 (diff)
random: move rand_initialize() earlier
Right now rand_initialize() is run as an early_initcall(), but it only depends on timekeeping_init() (for mixing ktime_get_real() into the pools). However, the call to boot_init_stack_canary() for stack canary initialization runs earlier, which triggers a warning at boot: random: get_random_bytes called from start_kernel+0x357/0x548 with crng_init=0 Instead, this moves rand_initialize() to after timekeeping_init(), and moves canary initialization here as well. Note that this warning may still remain for machines that do not have UEFI RNG support (which initializes the RNG pools during setup_arch()), or for x86 machines without RDRAND (or booting without "random.trust=on" or CONFIG_RANDOM_TRUST_CPU=y). Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index e247c45b2772..8757ed493b11 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1783,7 +1783,7 @@ EXPORT_SYMBOL(get_random_bytes_arch);
1783 * data into the pool to prepare it for use. The pool is not cleared 1783 * data into the pool to prepare it for use. The pool is not cleared
1784 * as that can only decrease the entropy in the pool. 1784 * as that can only decrease the entropy in the pool.
1785 */ 1785 */
1786static void init_std_data(struct entropy_store *r) 1786static void __init init_std_data(struct entropy_store *r)
1787{ 1787{
1788 int i; 1788 int i;
1789 ktime_t now = ktime_get_real(); 1789 ktime_t now = ktime_get_real();
@@ -1810,7 +1810,7 @@ static void init_std_data(struct entropy_store *r)
1810 * take care not to overwrite the precious per platform data 1810 * take care not to overwrite the precious per platform data
1811 * we were given. 1811 * we were given.
1812 */ 1812 */
1813static int rand_initialize(void) 1813int __init rand_initialize(void)
1814{ 1814{
1815 init_std_data(&input_pool); 1815 init_std_data(&input_pool);
1816 init_std_data(&blocking_pool); 1816 init_std_data(&blocking_pool);
@@ -1822,7 +1822,6 @@ static int rand_initialize(void)
1822 } 1822 }
1823 return 0; 1823 return 0;
1824} 1824}
1825early_initcall(rand_initialize);
1826 1825
1827#ifdef CONFIG_BLOCK 1826#ifdef CONFIG_BLOCK
1828void rand_initialize_disk(struct gendisk *disk) 1827void rand_initialize_disk(struct gendisk *disk)