diff options
| author | 2011-01-06 15:41:50 +0000 | |
|---|---|---|
| committer | 2011-01-06 15:41:50 +0000 | |
| commit | 5025fd4b336f51e7b48ee82358837f3af3a295f5 (patch) | |
| tree | 706d29aeef07b5ab4d67a2f944d534fb76e6c24f /sys/dev/rnd.c | |
| parent | Ugly hack, call session_schedule in the task pdu callback handler. (diff) | |
| download | wireguard-openbsd-5025fd4b336f51e7b48ee82358837f3af3a295f5.tar.xz wireguard-openbsd-5025fd4b336f51e7b48ee82358837f3af3a295f5.zip | |
make all /dev/*random nodes respond; in fact, don't even worry about
the minor number at all. The chances of an application ignoring the
error on /dev/random are *greater* than the risk of an application
getting bad data from it.
ok dlg tedu kjell
Diffstat (limited to 'sys/dev/rnd.c')
| -rw-r--r-- | sys/dev/rnd.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index edd07d06ed7..5bd85e00794 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.122 2011/01/04 19:42:22 deraadt Exp $ */ +/* $OpenBSD: rnd.c,v 1.123 2011/01/06 15:41:50 deraadt Exp $ */ /* * Copyright (c) 1996, 1997, 2000-2002 Michael Shalayeff. @@ -825,7 +825,7 @@ arc4random_uniform(u_int32_t upper_bound) int randomopen(dev_t dev, int flag, int mode, struct proc *p) { - return (minor(dev) < RND_NODEV ? 0 : ENXIO); + return 0; } int @@ -845,26 +845,13 @@ randomread(dev_t dev, struct uio *uio, int ioflag) buf = malloc(POOLBYTES, M_TEMP, M_WAITOK); - while (!ret && uio->uio_resid > 0) { + while (ret == 0 && uio->uio_resid > 0) { int n = min(POOLBYTES, uio->uio_resid); - switch (minor(dev)) { - case RND_RND: - ret = EIO; /* no chip -- error */ - break; - case RND_SRND: - case RND_URND: - case RND_ARND: - arc4random_buf(buf, n); - break; - default: - ret = ENXIO; - } - if (n != 0 && ret == 0) { - ret = uiomove((caddr_t)buf, n, uio); - if (!ret && uio->uio_resid > 0) - yield(); - } + arc4random_buf(buf, n); + ret = uiomove((caddr_t)buf, n, uio); + if (ret == 0 && uio->uio_resid > 0) + yield(); } free(buf, M_TEMP); @@ -877,9 +864,6 @@ randomwrite(dev_t dev, struct uio *uio, int flags) int ret = 0, newdata = 0; u_int32_t *buf; - if (minor(dev) == RND_RND) - return ENXIO; - if (uio->uio_resid == 0) return 0; |
