summaryrefslogtreecommitdiff
path: root/sys/dev/random.c
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2020-05-08 15:53:26 +0000
committerriastradh <riastradh@NetBSD.org>2020-05-08 15:53:26 +0000
commit59f8cd3117fb321eeb5be770a4a07df595acb1df (patch)
tree472278552f30997e65bdfdde3ed306953e181955 /sys/dev/random.c
parent1d82f9b3045cb2df3242025f9f1fe86b26b4db3b (diff)
Simplify /dev/random without reference to entropy_depletion.
Diffstat (limited to 'sys/dev/random.c')
-rw-r--r--sys/dev/random.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/sys/dev/random.c b/sys/dev/random.c
index f1d80258799..e8607af2fab 100644
--- a/sys/dev/random.c
+++ b/sys/dev/random.c
@@ -1,4 +1,4 @@
-/* $NetBSD: random.c,v 1.3 2020/05/07 19:05:51 riastradh Exp $ */
+/* $NetBSD: random.c,v 1.4 2020/05/08 15:53:26 riastradh Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.3 2020/05/07 19:05:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.4 2020/05/08 15:53:26 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -275,11 +275,10 @@ random_read(dev_t dev, struct uio *uio, int flags)
n = MIN(n, RANDOM_BUFSIZE);
/*
- * If we're `depleting' and this is /dev/random, clamp
- * to the smaller of the entropy capacity or the seed.
+ * Clamp /dev/random output to the entropy capacity and
+ * seed size. Programs can't rely on long reads.
*/
- if (__predict_false(atomic_load_relaxed(&entropy_depletion)) &&
- minor(dev) == RND_DEV_RANDOM) {
+ if (minor(dev) == RND_DEV_RANDOM) {
n = MIN(n, ENTROPY_CAPACITY);
n = MIN(n, sizeof seed);
/*
@@ -343,14 +342,11 @@ random_read(dev_t dev, struct uio *uio, int flags)
break;
/*
- * If we're `depleting' and this is /dev/random, stop
- * here, return what we have, and force the next read
- * to reseed. Could grab more from the pool if
- * possible without blocking, but that's more
- * work.
+ * If this is /dev/random, stop here, return what we
+ * have, and force the next read to reseed. Programs
+ * can't rely on /dev/random for long reads.
*/
- if (__predict_false(atomic_load_relaxed(&entropy_depletion)) &&
- minor(dev) == RND_DEV_RANDOM) {
+ if (minor(dev) == RND_DEV_RANDOM) {
error = 0;
break;
}