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.
This commit is contained in:
parent
2b38f13330
commit
77ebf39786
@ -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 @@ rnd_getmore(size_t byteswanted)
|
||||
{
|
||||
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. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user