diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-01-07 04:38:01 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-01-07 04:38:01 +0000 |
commit | 930a9cd1a981211e2e2383d17793ab6655f02e61 (patch) | |
tree | d18b8d487366f7898d08f27fcfb29f33fcbdcd9a /sys/dev/rnd.c | |
parent | fea76d25d86093f7282ff2412a1f32c2e7908250 (diff) |
since randomwrite() also has no blocking operations at all, we need to
do a yield, otherwise an accidental cat by root into /dev/random kind
of makes your machine hurt a lot.
Diffstat (limited to 'sys/dev/rnd.c')
-rw-r--r-- | sys/dev/rnd.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 4cb9856feb9..85982866df1 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.124 2011/01/06 22:49:10 deraadt Exp $ */ +/* $OpenBSD: rnd.c,v 1.125 2011/01/07 04:38:00 deraadt Exp $ */ /* * Copyright (c) 1996, 1997, 2000-2002 Michael Shalayeff. @@ -894,6 +894,8 @@ randomwrite(dev_t dev, struct uio *uio, int flags) while (n % sizeof(u_int32_t)) ((u_int8_t *)buf)[n++] = 0; add_entropy_words(buf, n / 4); + if (ret == 0 && uio->uio_resid > 0) + yield(); newdata = 1; } |