Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Remove cprng initialization order hack.



details:   https://anonhg.NetBSD.org/src/rev/e288e8969a0d
branches:  trunk
changeset: 971987:e288e8969a0d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon May 11 21:40:12 2020 +0000

description:
Remove cprng initialization order hack.

cprng_init now runs early enough that the hack should no longer be
needed to address PR port-arm32/55252.

diffstat:

 sys/kern/subr_cprng.c |  27 ++-------------------------
 1 files changed, 2 insertions(+), 25 deletions(-)

diffs (62 lines):

diff -r 7cddf9d3105e -r e288e8969a0d sys/kern/subr_cprng.c
--- a/sys/kern/subr_cprng.c     Mon May 11 21:38:54 2020 +0000
+++ b/sys/kern/subr_cprng.c     Mon May 11 21:40:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_cprng.c,v 1.39 2020/05/11 21:38:54 riastradh Exp $        */
+/*     $NetBSD: subr_cprng.c,v 1.40 2020/05/11 21:40:12 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.39 2020/05/11 21:38:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.40 2020/05/11 21:40:12 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/cprng.h>
@@ -102,7 +102,6 @@
 struct cprng_strong *user_cprng __read_mostly; /* IPL_NONE */
 
 static struct sysctllog *cprng_sysctllog __read_mostly;
-static bool cprng_initialized __read_mostly = false;
 
 void
 cprng_init(void)
@@ -129,9 +128,6 @@
            CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_INT /*lie*/, "arandom",
            SYSCTL_DESCR("Independent uniform random bytes, up to 256 bytes"),
            sysctl_kern_arandom, 0, NULL, 0, CTL_KERN, KERN_ARND, CTL_EOL);
-
-       /* Ready to go.  */
-       cprng_initialized = true;
 }
 
 /*
@@ -281,25 +277,6 @@
        int s;
 
        /*
-        * Some device drivers try to use cprng_strong in attach during
-        * autoconf, e.g. to randomly generate MAC addresses, before we
-        * percpu is available -- percpu is not available until after
-        * CPUs have been detected during autoconf.  We should make
-        * percpu available sooner, but for now this works around it.
-        */
-       if (__predict_false(!cprng_initialized)) {
-               struct nist_hash_drbg drbg;
-               entropy_extract(seed, sizeof seed, 0);
-               if (__predict_false(nist_hash_drbg_instantiate(&drbg,
-                           seed, sizeof seed, NULL, 0, NULL, 0)))
-                       panic("nist_hash_drbg_instantiate");
-               if (__predict_false(nist_hash_drbg_generate(&drbg, buf, len,
-                           NULL, 0)))
-                       panic("nist_hash_drbg_generate");
-               return len;
-       }
-
-       /*
         * Verify maximum request length.  Caller should really limit
         * their requests to 32 bytes to avoid spending much time with
         * preemption disabled -- use the 32 bytes to seed a private



Home | Main Index | Thread Index | Old Index