Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Ask on-demand entropy sources to produce enough dat...
details: https://anonhg.NetBSD.org/src/rev/d062dc3038a9
branches: trunk
changeset: 345352:d062dc3038a9
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat May 21 15:27:15 2016 +0000
description:
Ask on-demand entropy sources to produce enough data to fill buffer.
Remainder of fix for PR kern/51135: if there is an entropy source
that can produce arbitrarily much data, as in rump, then nothing
should ever block indefinitely waiting for data.
diffstat:
sys/kern/kern_rndq.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diffs (38 lines):
diff -r d2862611b399 -r d062dc3038a9 sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c Sat May 21 14:59:45 2016 +0000
+++ b/sys/kern/kern_rndq.c Sat May 21 15:27:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_rndq.c,v 1.88 2016/02/29 01:57:30 riastradh Exp $ */
+/* $NetBSD: kern_rndq.c,v 1.89 2016/05/21 15:27:15 riastradh Exp $ */
/*-
* Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.88 2016/02/29 01:57:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.89 2016/05/21 15:27:15 riastradh Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -258,6 +258,19 @@
{
krndsource_t *rs, *next;
+ /*
+ * Due to buffering in rnd_process_events, even if the entropy
+ * sources provide the requested number of bytes, users may not
+ * be woken because the data may be stuck in unfilled buffers.
+ * So ask for enough data to fill all the buffers.
+ *
+ * XXX Just get rid of this buffering and solve the
+ * /dev/random-as-side-channel-for-keystroke-timings a
+ * different way.
+ */
+ byteswanted = MAX(byteswanted,
+ MAX(RND_POOLBITS/NBBY, sizeof(uint32_t)*RND_SAMPLE_COUNT));
+
mutex_spin_enter(&rnd_global.lock);
LIST_FOREACH_SAFE(rs, &rnd_global.sources, list, next) {
/* Skip if the source is disabled. */
Home |
Main Index |
Thread Index |
Old Index