patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / char / random.c
index 6941fde..f51b541 100644 (file)
@@ -1586,7 +1586,7 @@ void rand_initialize_disk(struct gendisk *disk)
 }
 
 static ssize_t
-random_read(struct file * file, char * buf, size_t nbytes, loff_t *ppos)
+random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
 {
        DECLARE_WAITQUEUE(wait, current);
        ssize_t                 n, retval = 0, count = 0;
@@ -1666,7 +1666,7 @@ random_read(struct file * file, char * buf, size_t nbytes, loff_t *ppos)
 }
 
 static ssize_t
-urandom_read(struct file * file, char * buf,
+urandom_read(struct file * file, char __user * buf,
                      size_t nbytes, loff_t *ppos)
 {
        return extract_entropy(sec_random_state, buf, nbytes,
@@ -1690,13 +1690,13 @@ random_poll(struct file *file, poll_table * wait)
 }
 
 static ssize_t
-random_write(struct file * file, const char * buffer,
+random_write(struct file * file, const char __user * buffer,
             size_t count, loff_t *ppos)
 {
        int             ret = 0;
        size_t          bytes;
        __u32           buf[16];
-       const char      *p = buffer;
+       const char      __user *p = buffer;
        size_t          c = count;
 
        while (c > 0) {
@@ -1725,20 +1725,21 @@ static int
 random_ioctl(struct inode * inode, struct file * file,
             unsigned int cmd, unsigned long arg)
 {
-       int *p, *tmp, size, ent_count;
+       int *tmp, size, ent_count;
+       int __user *p = (int __user *)arg;
        int retval;
        unsigned long flags;
        
        switch (cmd) {
        case RNDGETENTCNT:
                ent_count = random_state->entropy_count;
-               if (put_user(ent_count, (int *) arg))
+               if (put_user(ent_count, p))
                        return -EFAULT;
                return 0;
        case RNDADDTOENTCNT:
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
-               if (get_user(ent_count, (int *) arg))
+               if (get_user(ent_count, p))
                        return -EFAULT;
                credit_entropy_store(random_state, ent_count);
                /*
@@ -1751,7 +1752,6 @@ random_ioctl(struct inode * inode, struct file * file,
        case RNDGETPOOL:
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
-               p = (int *) arg;
                if (get_user(size, p) ||
                    put_user(random_state->poolinfo.poolwords, p++))
                        return -EFAULT;
@@ -1786,14 +1786,13 @@ random_ioctl(struct inode * inode, struct file * file,
        case RNDADDENTROPY:
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
-               p = (int *) arg;
                if (get_user(ent_count, p++))
                        return -EFAULT;
                if (ent_count < 0)
                        return -EINVAL;
                if (get_user(size, p++))
                        return -EFAULT;
-               retval = random_write(file, (const char *) p,
+               retval = random_write(file, (const char __user *) p,
                                      size, &file->f_pos);
                if (retval < 0)
                        return retval;
@@ -1895,7 +1894,7 @@ static int change_poolsize(int poolsize)
 }
 
 static int proc_do_poolsize(ctl_table *table, int write, struct file *filp,
-                           void *buffer, size_t *lenp)
+                           void __user *buffer, size_t *lenp)
 {
        int     ret;
 
@@ -1909,9 +1908,9 @@ static int proc_do_poolsize(ctl_table *table, int write, struct file *filp,
        return change_poolsize(sysctl_poolsize);
 }
 
-static int poolsize_strategy(ctl_table *table, int *name, int nlen,
-                            void *oldval, size_t *oldlenp,
-                            void *newval, size_t newlen, void **context)
+static int poolsize_strategy(ctl_table *table, int __user *name, int nlen,
+                            void __user *oldval, size_t __user *oldlenp,
+                            void __user *newval, size_t newlen, void **context)
 {
        int     len;
        
@@ -1946,7 +1945,7 @@ static int poolsize_strategy(ctl_table *table, int *name, int nlen,
  * sysctl system call, it is returned as 16 bytes of binary data.
  */
 static int proc_do_uuid(ctl_table *table, int write, struct file *filp,
-                       void *buffer, size_t *lenp)
+                       void __user *buffer, size_t *lenp)
 {
        ctl_table       fake_table;
        unsigned char   buf[64], tmp_uuid[16], *uuid;
@@ -1971,9 +1970,9 @@ static int proc_do_uuid(ctl_table *table, int write, struct file *filp,
        return proc_dostring(&fake_table, write, filp, buffer, lenp);
 }
 
-static int uuid_strategy(ctl_table *table, int *name, int nlen,
-                        void *oldval, size_t *oldlenp,
-                        void *newval, size_t newlen, void **context)
+static int uuid_strategy(ctl_table *table, int __user *name, int nlen,
+                        void __user *oldval, size_t __user *oldlenp,
+                        void __user *newval, size_t newlen, void **context)
 {
        unsigned char   tmp_uuid[16], *uuid;
        unsigned int    len;