summaryrefslogtreecommitdiffstats
path: root/drivers/char/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 5db97f906..c980d5192 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1250,7 +1250,7 @@ static ssize_t extract_entropy(struct random_bucket *r, char * buf,
}
#if HASH_BUFFER_SIZE & 1 /* There's a middle word to deal with */
x = tmp[HASH_BUFFER_SIZE/2];
- add_entropy_words(r, x, (__u32)buf);
+ add_entropy_words(r, x, (__u32)((unsigned long)buf));
x ^= (x >> 16); /* Fold it in half */
((__u16 *)tmp)[HASH_BUFFER_SIZE-1] = (__u16)x;
#endif
@@ -1407,19 +1407,15 @@ random_ioctl(struct inode * inode, struct file * file,
switch (cmd) {
case RNDGETENTCNT:
- retval = verify_area(VERIFY_WRITE, (void *) arg, sizeof(int));
- if (retval)
- return(retval);
ent_count = random_state.entropy_count;
- put_user(ent_count, (int *) arg);
+ if (put_user(ent_count, (int *) arg))
+ return -EFAULT;
return 0;
case RNDADDTOENTCNT:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- retval = verify_area(VERIFY_READ, (void *) arg, sizeof(int));
- if (retval)
- return(retval);
- get_user(ent_count, (int *) arg);
+ if (get_user(ent_count, (int *) arg))
+ return -EFAULT;
/*
* Add i to entropy_count, limiting the result to be
* between 0 and POOLBITS.
@@ -1446,16 +1442,14 @@ random_ioctl(struct inode * inode, struct file * file,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
p = (int *) arg;
- retval = verify_area(VERIFY_WRITE, (void *) p, sizeof(int));
- if (retval)
- return(retval);
ent_count = random_state.entropy_count;
- put_user(ent_count, p++);
- retval = verify_area(VERIFY_WRITE, (void *) p, sizeof(int));
- if (retval)
- return(retval);
- get_user(size, p);
- put_user(POOLWORDS, p++);
+ if (put_user(ent_count, p++))
+ return -EFAULT;
+
+ if (get_user(size, p))
+ return -EFAULT;
+ if (put_user(POOLWORDS, p++))
+ return -EFAULT;
if (size < 0)
return -EINVAL;
if (size > POOLWORDS)
@@ -1467,16 +1461,12 @@ random_ioctl(struct inode * inode, struct file * file,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
p = (int *) arg;
- retval = verify_area(VERIFY_READ, (void *) p, 2*sizeof(int));
- if (retval)
- return(retval);
- get_user(ent_count, p++);
+ if (get_user(ent_count, p++))
+ return -EFAULT;
if (ent_count < 0)
return -EINVAL;
- get_user(size, p++);
- retval = verify_area(VERIFY_READ, (void *) p, size);
- if (retval)
- return retval;
+ if (get_user(size, p++))
+ return -EFAULT;
retval = random_write(file, (const char *) p,
size, &file->f_pos);
if (retval < 0)