Skip to content

Commit 9b25436

Browse files
keestytso
authored andcommitted
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: Kees Cook <keescook@chromium.org> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 9a47249 commit 9b25436

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,6 +3390,12 @@
33903390
ramdisk_size= [RAM] Sizes of RAM disks in kilobytes
33913391
See Documentation/blockdev/ramdisk.txt.
33923392

3393+
random.trust_cpu={on,off}
3394+
[KNL] Enable or disable trusting the use of the
3395+
CPU's random number generator (if available) to
3396+
fully seed the kernel's CRNG. Default is controlled
3397+
by CONFIG_RANDOM_TRUST_CPU.
3398+
33933399
ras=option[,option,...] [KNL] RAS-specific options
33943400

33953401
cec_disable [X86]

drivers/char/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,5 +566,5 @@ config RANDOM_TRUST_CPU
566566
that CPU manufacturer (perhaps with the insistence or mandate
567567
of a Nation State's intelligence or law enforcement agencies)
568568
has not installed a hidden back door to compromise the CPU's
569-
random number generation facilities.
570-
569+
random number generation facilities. This can also be configured
570+
at boot with "random.trust_cpu=on/off".

drivers/char/random.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,13 @@ static struct crng_state **crng_node_pool __read_mostly;
779779

780780
static void invalidate_batched_entropy(void);
781781

782+
static bool trust_cpu __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU);
783+
static int __init parse_trust_cpu(char *arg)
784+
{
785+
return kstrtobool(arg, &trust_cpu);
786+
}
787+
early_param("random.trust_cpu", parse_trust_cpu);
788+
782789
static void crng_initialize(struct crng_state *crng)
783790
{
784791
int i;
@@ -799,12 +806,10 @@ static void crng_initialize(struct crng_state *crng)
799806
}
800807
crng->state[i] ^= rv;
801808
}
802-
#ifdef CONFIG_RANDOM_TRUST_CPU
803-
if (arch_init) {
809+
if (trust_cpu && arch_init) {
804810
crng_init = 2;
805811
pr_notice("random: crng done (trusting CPU's manufacturer)\n");
806812
}
807-
#endif
808813
crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
809814
}
810815

0 commit comments

Comments
 (0)