]> git.baikalelectronics.ru Git - kernel.git/commit
random: fix CRNG initialization when random.trust_cpu=1
authorJon DeVree <nuxi@vault24.org>
Sat, 20 Apr 2019 03:35:16 +0000 (23:35 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 20 Apr 2019 03:35:16 +0000 (23:35 -0400)
commita44ea0843c3e1465a2fb212f80b3ea08e52f0bf8
tree96806087df69b7aaff6fe1a9606fba97d2bb3489
parent26717b13763ed82084c0679f30999196d882dc84
random: fix CRNG initialization when random.trust_cpu=1

When the system boots with random.trust_cpu=1 it doesn't initialize the
per-NUMA CRNGs because it skips the rest of the CRNG startup code. This
means that the code from eaef70dc9010 ("random: make /dev/urandom scalable
for silly userspace programs") is not used when random.trust_cpu=1.

crash> dmesg | grep random:
[    0.000000] random: get_random_bytes called from start_kernel+0x94/0x530 with crng_init=0
[    0.314029] random: crng done (trusting CPU's manufacturer)
crash> print crng_node_pool
$6 = (struct crng_state **) 0x0

After adding the missing call to numa_crng_init() the per-NUMA CRNGs are
initialized again:

crash> dmesg | grep random:
[    0.000000] random: get_random_bytes called from start_kernel+0x94/0x530 with crng_init=0
[    0.314031] random: crng done (trusting CPU's manufacturer)
crash> print crng_node_pool
$1 = (struct crng_state **) 0xffff9a915f4014a0

The call to invalidate_batched_entropy() was also missing. This is
important for architectures like PPC and S390 which only have the
arch_get_random_seed_* functions.

Fixes: e16c57df5506 ("random: add a config option to trust the CPU's hwrng")
Signed-off-by: Jon DeVree <nuxi@vault24.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
drivers/char/random.c