Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Kick on-demand entropy sources in rndsinks_distribute.



details:   https://anonhg.NetBSD.org/src/rev/eb3053b45164
branches:  trunk
changeset: 327193:eb3053b45164
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Mar 01 14:15:15 2014 +0000

description:
Kick on-demand entropy sources in rndsinks_distribute.

Partial workaround for indefinite hangs when entropy is scarce or
buffered up.  We need to do more to handle entropy that has been
buffered up -- see the comment for details -- but this will help for
now.

Problem noted by pooka.

diffstat:

 sys/kern/kern_rndsink.c |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r 24fdd5a67b2b -r eb3053b45164 sys/kern/kern_rndsink.c
--- a/sys/kern/kern_rndsink.c   Sat Mar 01 12:55:23 2014 +0000
+++ b/sys/kern/kern_rndsink.c   Sat Mar 01 14:15:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rndsink.c,v 1.7 2013/10/25 11:35:55 martin Exp $  */
+/*     $NetBSD: kern_rndsink.c,v 1.8 2014/03/01 14:15:15 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndsink.c,v 1.7 2013/10/25 11:35:55 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndsink.c,v 1.8 2014/03/01 14:15:15 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -210,7 +210,20 @@
 
        KASSERT(mutex_owned(&rndsinks_lock));
 
-       /* XXX Kick any on-demand entropy sources too.  */
+       /*
+        * XXX This should request only rndsink->rs_bytes bytes of
+        * entropy, but that might get buffered up indefinitely because
+        * kern_rndq has no bound on the duration before it will
+        * process queued entropy samples.  For now, request refilling
+        * the pool altogether so that the buffer will fill up and get
+        * processed.  Later, we ought to (a) bound the duration before
+        * queued entropy samples get processed, and (b) add a target
+        * or something -- as soon as we get that much from the entropy
+        * sources, distribute it.
+        */
+       mutex_spin_enter(&rndpool_mtx);
+       rnd_getmore(RND_POOLBITS / NBBY);
+       mutex_spin_exit(&rndpool_mtx);
 
        switch (rndsink->rsink_state) {
        case RNDSINK_IDLE:



Home | Main Index | Thread Index | Old Index