Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/kern Pull up following revision(s) (requested by rias...



details:   https://anonhg.NetBSD.org/src/rev/cbf7b985559f
branches:  netbsd-8
changeset: 852667:cbf7b985559f
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Nov 25 16:03:08 2019 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #1459):

        sys/kern/subr_cprng.c: revision 1.33

Use cprng_strong, not cprng_fast, for sysctl kern.arnd.

diffstat:

 sys/kern/subr_cprng.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (58 lines):

diff -r 59885b305d78 -r cbf7b985559f sys/kern/subr_cprng.c
--- a/sys/kern/subr_cprng.c     Mon Nov 25 16:01:25 2019 +0000
+++ b/sys/kern/subr_cprng.c     Mon Nov 25 16:03:08 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_cprng.c,v 1.27.10.1 2019/09/03 12:08:22 martin Exp $ */
+/*     $NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $ */
 
 /*-
  * Copyright (c) 2011-2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.1 2019/09/03 12:08:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -507,6 +507,7 @@
        mutex_exit(&cprng->cs_lock);
 }
 
+static ONCE_DECL(sysctl_prng_once);
 static cprng_strong_t *sysctl_prng;
 
 static int
@@ -526,10 +527,9 @@
 static int
 sysctl_kern_urnd(SYSCTLFN_ARGS)
 {
-       static ONCE_DECL(control);
        int v, rv;
 
-       RUN_ONCE(&control, makeprng);
+       RUN_ONCE(&sysctl_prng_once, makeprng);
        rv = cprng_strong(sysctl_prng, &v, sizeof(v), 0);
        if (rv == sizeof(v)) {
                struct sysctlnode node = *rnode;
@@ -558,6 +558,7 @@
        int error;
        void *v;
        struct sysctlnode node = *rnode;
+       size_t n __diagused;
 
        switch (*oldlenp) {
            case 0:
@@ -566,8 +567,10 @@
                if (*oldlenp > 256) {
                        return E2BIG;
                }
+               RUN_ONCE(&sysctl_prng_once, makeprng);
                v = kmem_alloc(*oldlenp, KM_SLEEP);
-               cprng_fast(v, *oldlenp);
+               n = cprng_strong(sysctl_prng, v, *oldlenp, 0);
+               KASSERT(n == *oldlenp);
                node.sysctl_data = v;
                node.sysctl_size = *oldlenp;
                error = sysctl_lookup(SYSCTLFN_CALL(&node));



Home | Main Index | Thread Index | Old Index