From 2cd55ac4fd423e53a1554f5a9e0765c1d2fd509e Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 15 Oct 2008 03:30:58 +0000 Subject: 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@ --- sys/dev/rnd.c | 7 +++++-- 1 file 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); -- cgit v1.2.3