diff options
author | 2000-10-20 03:30:05 +0000 | |
---|---|---|
committer | 2000-10-20 03:30:05 +0000 | |
commit | d70e038552b27c2666826324d0df678bd6f641f0 (patch) | |
tree | 92be1958b367f337855e72124cb969b7c058e19f | |
parent | strip and compress the ramdisk kernel on the cd, makes the image much (diff) | |
download | wireguard-openbsd-d70e038552b27c2666826324d0df678bd6f641f0.tar.xz wireguard-openbsd-d70e038552b27c2666826324d0df678bd6f641f0.zip |
fix ioctls; pointed out by Pawel Krawczyk <http://ceti.pl/~kravietz/>
-rw-r--r-- | sys/dev/rnd.c | 29 | ||||
-rw-r--r-- | sys/dev/rndioctl.h | 10 |
2 files changed, 26 insertions, 13 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 4df276058c1..4f750f7af2d 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.43 2000/08/21 01:52:18 jason Exp $ */ +/* $OpenBSD: rnd.c,v 1.44 2000/10/20 03:30:05 mickey Exp $ */ /* * random.c -- A strong random number generator @@ -1037,7 +1037,7 @@ randomioctl(dev, cmd, data, flag, p) int flag; struct proc *p; { - int ret = 0; + int s, ret = 0; u_int cnt; add_timer_randomness((u_long)p ^ (u_long)data ^ cmd); @@ -1052,38 +1052,51 @@ randomioctl(dev, cmd, data, flag, p) break; case RNDGETENTCNT: - ret = copyout(&random_state.entropy_count, data, - sizeof(random_state.entropy_count)); + s = splhigh(); + *(u_int *)data = random_state.entropy_count; + splx(s); break; case RNDADDTOENTCNT: if (suser(p->p_ucred, &p->p_acflag) != 0) ret = EPERM; else { - copyin(&cnt, data, sizeof(cnt)); + cnt = *(u_int *)data; + printf("%d\n", cnt); + s = splhigh(); random_state.entropy_count += cnt; if (random_state.entropy_count > POOLBITS) random_state.entropy_count = POOLBITS; + splx(s); } break; case RNDZAPENTCNT: if (suser(p->p_ucred, &p->p_acflag) != 0) ret = EPERM; - else + else { + s = splhigh(); random_state.entropy_count = 0; + splx(s); + } break; case RNDSTIRARC4: if (suser(p->p_ucred, &p->p_acflag) != 0) ret = EPERM; else if (random_state.entropy_count < 64) ret = EAGAIN; - else + else { + s = splhigh(); arc4random_initialized = 0; + splx(s); + } break; case RNDCLRSTATS: if (suser(p->p_ucred, &p->p_acflag) != 0) ret = EPERM; - else + else { + s = splhigh(); bzero(&rndstats, sizeof(rndstats)); + splx(s); + } break; default: ret = EINVAL; diff --git a/sys/dev/rndioctl.h b/sys/dev/rndioctl.h index e824a4bea67..31e0c0bed8f 100644 --- a/sys/dev/rndioctl.h +++ b/sys/dev/rndioctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rndioctl.h,v 1.8 2000/04/13 13:48:30 mickey Exp $ */ +/* $OpenBSD: rndioctl.h,v 1.9 2000/10/20 03:30:06 mickey Exp $ */ /* * Copyright (c) 1996,2000 Michael Shalayeff. @@ -46,10 +46,10 @@ struct rnd_pool_info { u_int32_t *buf; }; -#define RNDGETENTCNT _IOR('R', 0, sizeof(u_int)) -#define RNDADDTOENTCNT _IOW('R', 1, sizeof(u_int)) -#define RNDGETPOOL _IOWR('R', 2, sizeof(struct rnd_pool_info)) -#define RNDADDENTROPY _IOW('R', 3, sizeof(u_int)) +#define RNDGETENTCNT _IOR('R', 0, u_int) +#define RNDADDTOENTCNT _IOW('R', 1, u_int) +#define RNDGETPOOL _IOWR('R', 2, struct rnd_pool_info) +#define RNDADDENTROPY _IOW('R', 3, u_int) #define RNDZAPENTCNT _IO( 'R', 4) #define RNDSTIRARC4 _IO( 'R', 5) #define RNDCLRSTATS _IO( 'R', 6) |