From b93e5db80e6b8232e4c7b9e5e2f151a71ff9de81 Mon Sep 17 00:00:00 2001 From: riastradh Date: Sat, 21 May 2016 15:33:40 +0000 Subject: [PATCH] Use rnd_getmore as intended. No more essay needed here. Workaround for buffering got pushed into rnd_getmore, closer to the actual cause of the problem. --- sys/kern/kern_rndsink.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/sys/kern/kern_rndsink.c b/sys/kern/kern_rndsink.c index 4857bc08152c..1ad142425ecb 100644 --- a/sys/kern/kern_rndsink.c +++ b/sys/kern/kern_rndsink.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_rndsink.c,v 1.16 2015/04/21 04:24:16 riastradh Exp $ */ +/* $NetBSD: kern_rndsink.c,v 1.17 2016/05/21 15:33:40 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_rndsink.c,v 1.16 2015/04/21 04:24:16 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_rndsink.c,v 1.17 2016/05/21 15:33:40 riastradh Exp $"); #include #include @@ -142,21 +142,10 @@ rndsinks_enqueue(struct rndsink *rndsink) KASSERT(mutex_owned(&rndsinks.lock)); - /* - * 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. To work around this, we are - * a little too incestuous with kern_rndq: we avoid marking polled - * sources "fast" there, and know here that for non-fast sources, - * that code will buffer two ints worth of data per source. - * 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. - */ - rnd_getmore(MAX(rndsink->rsink_bytes, 2 * sizeof(uint32_t))); + /* Kick on-demand entropy sources. */ + rnd_getmore(rndsink->rsink_bytes); + /* Ensure this rndsink is on the queue. */ switch (rndsink->rsink_state) { case RNDSINK_IDLE: /* Not on the queue and nobody is handling it. */