Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/arch/x86/x86 Pull up following revision(s) (requested...
details: https://anonhg.NetBSD.org/src/rev/244e53281a9a
branches: netbsd-9
changeset: 460735:244e53281a9a
user: martin <martin%NetBSD.org@localhost>
date: Fri Nov 01 18:17:55 2019 +0000
description:
Pull up following revision(s) (requested by taca in ticket #390):
sys/arch/x86/x86/cpu_rng.c: revision 1.10
Check CPU support of RDRAND before calling cpu_rng_rdrand().
cpu_earlyrng() checks CPU support of RDSEED and RDRAND before calling
cpu_rng_rdseed() and cpu_rng_rdrand().
But cpu_rng_rdseed() did not check CPU support of RDRAND and system had
crashed on such an environment. There is no such case with real CPU but
some VM environment.
Fix kern/54655 and confirmed by msaitoh@.
Needs pullup to netbsd-9.
diffstat:
sys/arch/x86/x86/cpu_rng.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diffs (39 lines):
diff -r f3559da510c6 -r 244e53281a9a sys/arch/x86/x86/cpu_rng.c
--- a/sys/arch/x86/x86/cpu_rng.c Fri Nov 01 18:14:45 2019 +0000
+++ b/sys/arch/x86/x86/cpu_rng.c Fri Nov 01 18:17:55 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_rng.c,v 1.9 2018/08/22 12:07:43 maxv Exp $ */
+/* $NetBSD: cpu_rng.c,v 1.9.4.1 2019/11/01 18:17:55 martin Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -53,6 +53,8 @@
CPU_RNG_VIA
} cpu_rng_mode __read_mostly = CPU_RNG_NONE;
+static bool has_rdrand;
+
bool
cpu_rng_init(void)
{
@@ -131,7 +133,10 @@
* to be seeded even in this case.
*/
exhausted:
- return cpu_rng_rdrand(out);
+ if (has_rdrand)
+ return cpu_rng_rdrand(out);
+ else
+ return 0;
}
static size_t
@@ -213,7 +218,7 @@
int i;
bool has_rdseed = (cpu_feature[5] & CPUID_SEF_RDSEED) != 0;
- bool has_rdrand = (cpu_feature[1] & CPUID2_RDRAND) != 0;
+ has_rdrand = (cpu_feature[1] & CPUID2_RDRAND) != 0;
KASSERT(sz + sizeof(uint64_t) <= SHA512_DIGEST_LENGTH);
Home |
Main Index |
Thread Index |
Old Index