random: remove "nordrand" flag in favor of "random.trust_cpu"
Subsystems (2)
PATCH 1/1 random: remove "nordrand" flag in favor of "random.trust_cpu"
The decision of whether or not to trust RDRAND is controlled by the "random.trust_cpu" boot time parameter or the CONFIG_RANDOM_TRUST_CPU compile time default. The "nordrand" flag was added during the early days of RDRAND, when there were worries that merely using its values could compromise the RNG. However, these days, RDRAND values are not used directly but always go through the RNG's hash function, making "nordrand" no longer useful.
Rather, the correct switch is "random.trust_cpu", which not only handles the relevant trust issue directly, but also is general to multiple CPU types, not just x86.
However, x86 RDRAND does have a history of being occassionally problematic. Prior, when the kernel would notice something strange, it'd warn in dmesg and suggest enabling "nordrand". We can improve on that by making the test a little bit better and then taking the step of automatically disabling "nordrand" if we detect it's problematic.
Also extend the basic sanity test to RDSEED in addition to RDRAND, and disable both if either one fails.
---
This patch builds on top of v4 of "random: remove CONFIG_ARCH_RANDOM":
https://lore.kernel.org/lkml/[email protected]/
.../admin-guide/kernel-parameters.txt | 5 -- arch/x86/kernel/cpu/amd.c | 2 +- arch/x86/kernel/cpu/rdrand.c | 73 +++++++++---------- 3 files changed, 36 insertions(+), 44 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -5
@@ -3733,11 +3733,6 @@ noreplace-smp [X86-32,SMP] Don't replace SMP instructions with UP alternatives - nordrand [X86] Disable kernel use of the RDRAND and - RDSEED instructions even if they are supported - by the processor. RDRAND and RDSEED are still - available to user space applications. - noresume [SWSUSP] Disables resume and restores original swap space.
arch/x86/kernel/cpu/amd.c +1 -1
@@ -808,7 +808,7 @@ static void clear_rdrand_cpuid_bit(struct cpuinfo_x86 *c)return ;/* -* The nordrand option can clear X86_FEATURE_RDRAND, so check for +* The self test can clear X86_FEATURE_RDRAND, so check for * RDRAND support using the CPUID function directly. */ if (!(cpuid_ecx (1 ) &BIT (30 )) || rdrand_force)
arch/x86/kernel/cpu/rdrand.c +35 -38
89 lines not on this page · raw message
Signature · 1 line
2.35.1
Randy Dunlap
reviewerHi Jason,
Quoted 8 lines · Jason A. Donenfeld
The decision of whether or not to trust RDRAND is controlled by the "random.trust_cpu" boot time parameter or the
CONFIG_RANDOM_TRUST_CPUcompile time default. The "nordrand" flag was added during the early days of RDRAND, when there were worries that merely using its values could compromise the RNG. However, these days, RDRAND values are not used directly but always go through the RNG's hash function, making "nordrand" no longer useful.
Quoted 5 lines
Rather, the correct switch is "random.trust_cpu", which not only handles the relevant trust issue directly, but also is general to multiple CPU types, not just x86.
However, x86 RDRAND does have a history of being occassionally
occasionally
Quoted 4 lines
problematic. Prior, when the kernel would notice something strange, it'd warn in dmesg and suggest enabling "nordrand". We can improve on that by making the test a little bit better and then taking the step of automatically disabling "nordrand" if we detect it's problematic.
enabling
? I.e., disabling RDRAND and RDSEED.
Quoted 23 lines
Also extend the basic sanity test to RDSEED in addition to RDRAND, and disable both if either one fails.
Cc Theodore Ts'o <[email protected]>Suggested-by H. Peter Anvin <[email protected]>Suggested-by Borislav Petkov <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>---
This patch builds on top of v4 of "random: removeCONFIG_ARCH_RANDOM":
https://lore.kernel.org/lkml/[email protected]/.../admin-guide/kernel-parameters.txt | 5 -- arch/x86/kernel/cpu/amd.c | 2 +- arch/x86/kernel/cpu/rdrand.c | 73 +++++++++---------- 3 files changed, 36 insertions(+), 44 deletions(-)arch/x86/kernel/cpu/amd.c +0
-0
arch/x86/kernel/cpu/amd.c static void clear_rdrand_cpuid_bit(struct cpuinfo_x86 *c) · line 811
Quoted 5 lines
arch/x86/kernel/cpu/amd.c +1
-1@@ -808,7 +808,7 @@ static void clear_rdrand_cpuid_bit(struct cpuinfo_x86 *c)return ;/* -* The nordrand option can clear X86_FEATURE_RDRAND, so check for +* The self test can clear X86_FEATURE_RDRAND, so check for
Preferably: self-test
Quoted 3 lines
arch/x86/kernel/cpu/amd.c +0
-0* RDRAND support using the CPUID function directly. */ if (!(cpuid_ecx (1 ) &BIT (30 )) || rdrand_force)
Signature · 1 line
~Randy
Hi Randy,
Quoted 10 lines · Randy Dunlap
Quoted 1 line
However, x86 RDRAND does have a history of being occassionally
occasionally
Quoted 1 line
automatically disabling "nordrand" if we detect it's problematic.
? I.e., disabling RDRAND and RDSEED.
arch/x86/kernel/cpu/amd.c static void clear_rdrand_cpuid_bit(struct cpuinfo_x86 *c) · line 811
Quoted 2 lines
arch/x86/kernel/cpu/amd.c +1
-1-* The nordrand option can clear X86_FEATURE_RDRAND, so check for +* The self test can clear X86_FEATURE_RDRAND, so check for Preferably: self-test
Thanks. Fixing all of those.
Jason
PATCH v2 1/1 x86/rdrand: Remove "nordrand" flag in favor of "random.trust_cpu"
The decision of whether or not to trust RDRAND is controlled by the "random.trust_cpu" boot time parameter or the CONFIG_RANDOM_TRUST_CPU compile time default. The "nordrand" flag was added during the early days of RDRAND, when there were worries that merely using its values could compromise the RNG. However, these days, RDRAND values are not used directly but always go through the RNG's hash function, making "nordrand" no longer useful.
Rather, the correct switch is "random.trust_cpu", which not only handles the relevant trust issue directly, but also is general to multiple CPU types, not just x86.
However, x86 RDRAND does have a history of being occasionally problematic. Prior, when the kernel would notice something strange, it'd warn in dmesg and suggest enabling "nordrand". We can improve on that by making the test a little bit better and then taking the step of automatically disabling RDRAND if we detect it's problematic.
Also extend the basic sanity test to RDSEED in addition to RDRAND, and disable both if either one fails.
---
This is a tip-ish commit, but it relies on the CONFIG_ARCH_RANDOM commit in the random tree, so I'll take this through the random tree to avoid conflicts.
Changes v1->v2:
- [Borislav] Reformat into tip-style commit to be taken through random tree.
- [Randy] Fix typos.
.../admin-guide/kernel-parameters.txt | 5 -- arch/x86/kernel/cpu/amd.c | 2 +- arch/x86/kernel/cpu/rdrand.c | 73 +++++++++---------- 3 files changed, 36 insertions(+), 44 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -5
@@ -3733,11 +3733,6 @@ noreplace-smp [X86-32,SMP] Don't replace SMP instructions with UP alternatives - nordrand [X86] Disable kernel use of the RDRAND and - RDSEED instructions even if they are supported - by the processor. RDRAND and RDSEED are still - available to user space applications. - noresume [SWSUSP] Disables resume and restores original swap space.
arch/x86/kernel/cpu/amd.c +1 -1
@@ -808,7 +808,7 @@ static void clear_rdrand_cpuid_bit(struct cpuinfo_x86 *c)return ;/* -* The nordrand option can clear X86_FEATURE_RDRAND, so check for +* The self-test can clear X86_FEATURE_RDRAND, so check for * RDRAND support using the CPUID function directly. */ if (!(cpuid_ecx (1 ) &BIT (30 )) || rdrand_force)
arch/x86/kernel/cpu/rdrand.c +35 -38
89 lines not on this page · raw message
Signature · 1 line
2.35.1
Re: [PATCH random v2] x86/rdrand: Remove "nordrand" flag in favor of "random.trust_cpu"
Quoted 26 lines · Jason A. Donenfeld
The decision of whether or not to trust RDRAND is controlled by the "random.trust_cpu" boot time parameter or the
CONFIG_RANDOM_TRUST_CPUcompile time default. The "nordrand" flag was added during the early days of RDRAND, when there were worries that merely using its values could compromise the RNG. However, these days, RDRAND values are not used directly but always go through the RNG's hash function, making "nordrand" no longer useful.Rather, the correct switch is "random.trust_cpu", which not only handles the relevant trust issue directly, but also is general to multiple CPU types, not just x86.
However, x86 RDRAND does have a history of being occasionally problematic. Prior, when the kernel would notice something strange, it'd warn in dmesg and suggest enabling "nordrand". We can improve on that by making the test a little bit better and then taking the step of automatically disabling RDRAND if we detect it's problematic.
Also extend the basic sanity test to RDSEED in addition to RDRAND, and disable both if either one fails.
Cc Theodore Ts'o <[email protected]>Suggested-by H. Peter Anvin <[email protected]>Suggested-by Borislav Petkov <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>
Quoted 4 lines
---
This is a tip-ish commit, but it relies on theCONFIG_ARCH_RANDOMcommit in the random tree, so I'll take this through the random tree to avoid conflicts.
Signature · 6 lines
Regards/Gruss,
Boris.
SUSE Software Solutions Germany GmbH
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
(HRB 36809, AG Nürnberg)PATCH v3 1/1 x86/rdrand: Remove "nordrand" flag in favor of "random.trust_cpu"
In reply to Jason A. DonenfeldThe decision of whether or not to trust RDRAND is controlled by the "random.trust_cpu" boot time parameter or the CONFIG_RANDOM_TRUST_CPU compile time default. The "nordrand" flag was added during the early days of RDRAND, when there were worries that merely using its values could compromise the RNG. However, these days, RDRAND values are not used directly but always go through the RNG's hash function, making "nordrand" no longer useful.
Rather, the correct switch is "random.trust_cpu", which not only handles the relevant trust issue directly, but also is general to multiple CPU types, not just x86.
However, x86 RDRAND does have a history of being occasionally problematic. Prior, when the kernel would notice something strange, it'd warn in dmesg and suggest enabling "nordrand". We can improve on that by making the test a little bit better and then taking the step of automatically disabling RDRAND if we detect it's problematic.
Also disable RDSEED if the RDRAND test fails.
---
Changes v2->v3:
- We can't call rdseed in a loop like we can rdrand because it's meant to fail (return false) more often.
.../admin-guide/kernel-parameters.txt | 5 -- arch/x86/kernel/cpu/amd.c | 2 +- arch/x86/kernel/cpu/rdrand.c | 57 +++++++------------ 3 files changed, 22 insertions(+), 42 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -5
@@ -3733,11 +3733,6 @@ noreplace-smp [X86-32,SMP] Don't replace SMP instructions with UP alternatives - nordrand [X86] Disable kernel use of the RDRAND and - RDSEED instructions even if they are supported - by the processor. RDRAND and RDSEED are still - available to user space applications. - noresume [SWSUSP] Disables resume and restores original swap space.
arch/x86/kernel/cpu/amd.c +1 -1
@@ -808,7 +808,7 @@ static void clear_rdrand_cpuid_bit(struct cpuinfo_x86 *c)return ;/* -* The nordrand option can clear X86_FEATURE_RDRAND, so check for +* The self-test can clear X86_FEATURE_RDRAND, so check for * RDRAND support using the CPUID function directly. */ if (!(cpuid_ecx (1 ) &BIT (30 )) || rdrand_force)
arch/x86/kernel/cpu/rdrand.c +21 -36
75 lines not on this page · raw message
Signature · 1 line
2.35.1