Module Name: src Committed By: pooka Date: Mon May 16 16:31:07 UTC 2016
Modified Files: src/sys/rump/dev/lib/librnd: rnd_component.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/rump/dev/lib/librnd/rnd_component.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/dev/lib/librnd/rnd_component.c diff -u src/sys/rump/dev/lib/librnd/rnd_component.c:1.3 src/sys/rump/dev/lib/librnd/rnd_component.c:1.4 --- src/sys/rump/dev/lib/librnd/rnd_component.c:1.3 Tue Jan 26 23:12:16 2016 +++ src/sys/rump/dev/lib/librnd/rnd_component.c Mon May 16 16:31:07 2016 @@ -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_COMPONENT(RUMP_COMPONENT_DEV) 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 */ + } +}