Module Name:    src
Committed By:   martin
Date:           Fri Aug 15 12:56:24 UTC 2014

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

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #22):
        sys/kern/subr_cprng.c: revision 1.25
Lock cprng->cs_lock around rndsink_request to avoid race with callback.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.24.2.1 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 src/sys/kern/subr_cprng.c:1.24.2.1
--- src/sys/kern/subr_cprng.c:1.24	Sun Aug 10 16:44:36 2014
+++ src/sys/kern/subr_cprng.c	Fri Aug 15 12:56:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cprng.c,v 1.24 2014/08/10 16:44:36 tls Exp $ */
+/*	$NetBSD: subr_cprng.c,v 1.24.2.1 2014/08/15 12:56:24 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 2014/08/10 16:44:36 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.24.2.1 2014/08/15 12:56:24 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -151,6 +151,7 @@ cprng_strong_create(const char *name, in
 
 	/* Get some initial entropy.  Record whether it is full entropy.  */
 	uint8_t seed[NIST_BLOCK_KEYLEN_BYTES];
+	mutex_enter(&cprng->cs_lock);
 	cprng->cs_ready = rndsink_request(cprng->cs_rndsink, seed,
 	    sizeof(seed));
 	if (nist_ctr_drbg_instantiate(&cprng->cs_drbg, seed, sizeof(seed),
@@ -168,6 +169,7 @@ cprng_strong_create(const char *name, in
 	if (!cprng->cs_ready && !ISSET(flags, CPRNG_INIT_ANY))
 		printf("cprng %s: creating with partial entropy\n",
 		    cprng->cs_name);
+	mutex_exit(&cprng->cs_lock);
 
 	return cprng;
 }

Reply via email to