aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-09-09 08:54:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-09-09 08:54:05 -0400
commit3243a89dcbd8f5810b72ee0903d349bd000c4c9d (patch)
tree84ffeb32740ec63c265cf92fbc980fb53e5270a4 /drivers
parent1d22577703b32f15d189466bd9c7f1973a295529 (diff)
parent9b25436662d5fb4c66eb527ead53cab15f596ee0 (diff)
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random
Pull random driver fix from Ted Ts'o: "Fix things so the choice of whether or not to trust RDRAND to initialize the CRNG is configurable via the boot option random.trust_cpu={on,off}" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random: random: make CPU trust a boot parameter
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/random.c11
2 files changed, 10 insertions, 5 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index ce277ee0a28a..40728491f37b 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -566,5 +566,5 @@ config RANDOM_TRUST_CPU
566 that CPU manufacturer (perhaps with the insistence or mandate 566 that CPU manufacturer (perhaps with the insistence or mandate
567 of a Nation State's intelligence or law enforcement agencies) 567 of a Nation State's intelligence or law enforcement agencies)
568 has not installed a hidden back door to compromise the CPU's 568 has not installed a hidden back door to compromise the CPU's
569 random number generation facilities. 569 random number generation facilities. This can also be configured
570 570 at boot with "random.trust_cpu=on/off".
diff --git a/drivers/char/random.c b/drivers/char/random.c
index bf5f99fc36f1..c75b6cdf0053 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -779,6 +779,13 @@ static struct crng_state **crng_node_pool __read_mostly;
779 779
780static void invalidate_batched_entropy(void); 780static void invalidate_batched_entropy(void);
781 781
782static bool trust_cpu __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU);
783static int __init parse_trust_cpu(char *arg)
784{
785 return kstrtobool(arg, &trust_cpu);
786}
787early_param("random.trust_cpu", parse_trust_cpu);
788
782static void crng_initialize(struct crng_state *crng) 789static void crng_initialize(struct crng_state *crng)
783{ 790{
784 int i; 791 int i;
@@ -799,12 +806,10 @@ static void crng_initialize(struct crng_state *crng)
799 } 806 }
800 crng->state[i] ^= rv; 807 crng->state[i] ^= rv;
801 } 808 }
802#ifdef CONFIG_RANDOM_TRUST_CPU 809 if (trust_cpu && arch_init) {
803 if (arch_init) {
804 crng_init = 2; 810 crng_init = 2;
805 pr_notice("random: crng done (trusting CPU's manufacturer)\n"); 811 pr_notice("random: crng done (trusting CPU's manufacturer)\n");
806 } 812 }
807#endif
808 crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1; 813 crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
809} 814}
810 815