Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Lock cprng->cs_lock around rndsink_request to avoid...
details: https://anonhg.NetBSD.org/src/rev/b12bc6056473
branches: trunk
changeset: 801712:b12bc6056473
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Aug 14 16:28:30 2014 +0000
description:
Lock cprng->cs_lock around rndsink_request to avoid race with callback.
diffstat:
sys/kern/subr_cprng.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diffs (34 lines):
diff -r 7a3b64b0c00e -r b12bc6056473 sys/kern/subr_cprng.c
--- a/sys/kern/subr_cprng.c Thu Aug 14 16:27:55 2014 +0000
+++ b/sys/kern/subr_cprng.c Thu Aug 14 16:28:30 2014 +0000
@@ -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.25 2014/08/14 16:28:30 riastradh 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.25 2014/08/14 16:28:30 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -151,6 +151,7 @@
/* 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 @@
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;
}
Home |
Main Index |
Thread Index |
Old Index