Commit 9b254366 authored by Kees Cook's avatar Kees Cook Committed by Theodore Ts'o

random: make CPU trust a boot parameter

Instead of forcing a distro or other system builder to choose
at build time whether the CPU is trusted for CRNG seeding via
CONFIG_RANDOM_TRUST_CPU, provide a boot-time parameter for end users to
control the choice. The CONFIG will set the default state instead.
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 9a47249d
...@@ -3390,6 +3390,12 @@ ...@@ -3390,6 +3390,12 @@
ramdisk_size= [RAM] Sizes of RAM disks in kilobytes ramdisk_size= [RAM] Sizes of RAM disks in kilobytes
See Documentation/blockdev/ramdisk.txt. See Documentation/blockdev/ramdisk.txt.
random.trust_cpu={on,off}
[KNL] Enable or disable trusting the use of the
CPU's random number generator (if available) to
fully seed the kernel's CRNG. Default is controlled
by CONFIG_RANDOM_TRUST_CPU.
ras=option[,option,...] [KNL] RAS-specific options ras=option[,option,...] [KNL] RAS-specific options
cec_disable [X86] cec_disable [X86]
......
...@@ -566,5 +566,5 @@ config RANDOM_TRUST_CPU ...@@ -566,5 +566,5 @@ config RANDOM_TRUST_CPU
that CPU manufacturer (perhaps with the insistence or mandate that CPU manufacturer (perhaps with the insistence or mandate
of a Nation State's intelligence or law enforcement agencies) of a Nation State's intelligence or law enforcement agencies)
has not installed a hidden back door to compromise the CPU's has not installed a hidden back door to compromise the CPU's
random number generation facilities. random number generation facilities. This can also be configured
at boot with "random.trust_cpu=on/off".
...@@ -779,6 +779,13 @@ static struct crng_state **crng_node_pool __read_mostly; ...@@ -779,6 +779,13 @@ static struct crng_state **crng_node_pool __read_mostly;
static void invalidate_batched_entropy(void); static void invalidate_batched_entropy(void);
static bool trust_cpu __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU);
static int __init parse_trust_cpu(char *arg)
{
return kstrtobool(arg, &trust_cpu);
}
early_param("random.trust_cpu", parse_trust_cpu);
static void crng_initialize(struct crng_state *crng) static void crng_initialize(struct crng_state *crng)
{ {
int i; int i;
...@@ -799,12 +806,10 @@ static void crng_initialize(struct crng_state *crng) ...@@ -799,12 +806,10 @@ static void crng_initialize(struct crng_state *crng)
} }
crng->state[i] ^= rv; crng->state[i] ^= rv;
} }
#ifdef CONFIG_RANDOM_TRUST_CPU if (trust_cpu && arch_init) {
if (arch_init) {
crng_init = 2; crng_init = 2;
pr_notice("random: crng done (trusting CPU's manufacturer)\n"); pr_notice("random: crng done (trusting CPU's manufacturer)\n");
} }
#endif
crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1; crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment