Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/dev/lib/librnd Add workaround for PR kern/51135
details: https://anonhg.NetBSD.org/src/rev/020c72a59944
branches: trunk
changeset: 345280:020c72a59944
user: pooka <pooka%NetBSD.org@localhost>
date: Mon May 16 16:31:07 2016 +0000
description:
Add workaround for PR kern/51135
If the rnd component is present, load extra initial entropy to avoid
/dev/random not being able to request it on demand. The extra initial
entropy will allow a few instances of /dev/random, but will eventually
go into the failure mode described in the PR.
diffstat:
sys/rump/dev/lib/librnd/rnd_component.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diffs (49 lines):
diff -r 84c36ffe9f09 -r 020c72a59944 sys/rump/dev/lib/librnd/rnd_component.c
--- a/sys/rump/dev/lib/librnd/rnd_component.c Mon May 16 15:09:29 2016 +0000
+++ b/sys/rump/dev/lib/librnd/rnd_component.c Mon May 16 16:31:07 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rnd_component.c,v 1.3 2016/01/26 23:12:16 pooka Exp $ */
+/* $NetBSD: rnd_component.c,v 1.4 2016/05/16 16:31:07 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rnd_component.c,v 1.3 2016/01/26 23:12:16 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rnd_component.c,v 1.4 2016/05/16 16:31:07 pooka Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -63,3 +63,30 @@
rump_pdev_add(rndattach, 4);
rnd_init();
}
+
+/*
+ * XXX: the following hack works around PR kern/51135 and should ASAP be
+ * nuked to and then from orbit.
+ */
+#define RNDPRELOAD 256
+#include <sys/rndio.h>
+RUMP_COMPONENT(RUMP_COMPONENT_POSTINIT)
+{
+ rnddata_t *rd;
+ size_t dsize, i;
+
+ CTASSERT(RNDPRELOAD <= sizeof(rd->data));
+
+ aprint_verbose("/dev/random: "
+ "loading initial entropy to workaround PR kern/51135\n");
+ rd = kmem_alloc(sizeof(*rd), KM_SLEEP);
+ for (i = 0; i < RNDPRELOAD; i += dsize) {
+ if (rumpuser_getrandom(rd->data,
+ RNDPRELOAD-i, RUMPUSER_RANDOM_HARD, &dsize) != 0)
+ panic("rumpuser_getrandom failed"); /* XXX */
+ rd->len = dsize;
+ rd->entropy = dsize*NBBY;
+ if (rnd_system_ioctl(NULL, RNDADDDATA, rd))
+ panic("rnd_system_ioctl failed"); /* XXX */
+ }
+}
Home |
Main Index |
Thread Index |
Old Index