summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-10-15 03:30:58 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-10-15 03:30:58 +0000
commit2cd55ac4fd423e53a1554f5a9e0765c1d2fd509e (patch)
tree3619cc57ffc99bcc88dc8aed5b48e6f8ae2ad778
parent493512c0507824c5a60a55fcc12fb3a2ed7085a2 (diff)
kernel/5592: yield() between copying out large chunks of random data to
userspace - mitigates an effective DoS since generating these can hog the CPU at splhigh() feedback & ok tedu@ deraadt@
-rw-r--r--sys/dev/rnd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c
index d8d62fa92b7..9bb08acc845 100644
--- a/sys/dev/rnd.c
+++ b/sys/dev/rnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rnd.c,v 1.94 2008/10/10 20:13:11 deraadt Exp $ */
+/* $OpenBSD: rnd.c,v 1.95 2008/10/15 03:30:57 djm Exp $ */
/*
* rnd.c -- A strong random number generator
@@ -1057,8 +1057,11 @@ randomread(dev_t dev, struct uio *uio, int ioflag)
default:
ret = ENXIO;
}
- if (n != 0 && ret == 0)
+ if (n != 0 && ret == 0) {
ret = uiomove((caddr_t)buf, n, uio);
+ if (!ret && uio->uio_resid > 0)
+ yield();
+ }
}
free(buf, M_TEMP);