Module Name:    src
Committed By:   martin
Date:           Mon Nov 25 15:46:39 UTC 2019

Modified Files:
        src/sys/kern [netbsd-7]: subr_cprng.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1714):

        sys/kern/subr_cprng.c: revision 1.33

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


To generate a diff of this commit:
cvs rdiff -u -r1.24.2.2 -r1.24.2.3 src/sys/kern/subr_cprng.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_cprng.c
diff -u src/sys/kern/subr_cprng.c:1.24.2.2 src/sys/kern/subr_cprng.c:1.24.2.3
--- src/sys/kern/subr_cprng.c:1.24.2.2	Tue Sep  3 12:20:43 2019
+++ src/sys/kern/subr_cprng.c	Mon Nov 25 15:46:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cprng.c,v 1.24.2.2 2019/09/03 12:20:43 martin Exp $ */
+/*	$NetBSD: subr_cprng.c,v 1.24.2.3 2019/11/25 15:46:39 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.24.2.2 2019/09/03 12:20:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.24.2.3 2019/11/25 15:46:39 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -508,6 +508,7 @@ cprng_strong_rndsink_callback(void *cont
 	mutex_exit(&cprng->cs_lock);
 }
 
+static ONCE_DECL(sysctl_prng_once);
 static cprng_strong_t *sysctl_prng;
 
 static int
@@ -527,10 +528,9 @@ makeprng(void)
 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;
@@ -559,6 +559,7 @@ sysctl_kern_arnd(SYSCTLFN_ARGS)
 	int error;
 	void *v;
 	struct sysctlnode node = *rnode;
+	size_t n __diagused;
 
 	switch (*oldlenp) {
 	    case 0:
@@ -567,8 +568,10 @@ sysctl_kern_arnd(SYSCTLFN_ARGS)
 		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));

Reply via email to