Commit 1fbd4d92 authored by Linus Torvalds's avatar Linus Torvalds

ppc64: check more of the user access functions for proper arguments.

parent 77ff9cbc
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
#define VERIFY_READ 0 #define VERIFY_READ 0
#define VERIFY_WRITE 1 #define VERIFY_WRITE 1
extern long not_a_user_address;
#define check_user_ptr(x) \
(void) ({ void __user * __userptr = (__typeof__(*(x)) *)&not_a_user_address; __userptr; })
/* /*
* The fs value determines whether argument validity checking should be * The fs value determines whether argument validity checking should be
* performed or not. If get_fs() == USER_DS, checking is performed, with * performed or not. If get_fs() == USER_DS, checking is performed, with
...@@ -54,7 +58,7 @@ ...@@ -54,7 +58,7 @@
(((segment).seg & (addr | size )) == 0) (((segment).seg & (addr | size )) == 0)
#define access_ok(type,addr,size) \ #define access_ok(type,addr,size) \
__access_ok(((unsigned long)(addr)),(size),get_fs()) __access_ok(((__force unsigned long)(addr)),(size),get_fs())
static inline int verify_area(int type, const void __user *addr, unsigned long size) static inline int verify_area(int type, const void __user *addr, unsigned long size)
{ {
...@@ -116,6 +120,7 @@ extern long __put_user_bad(void); ...@@ -116,6 +120,7 @@ extern long __put_user_bad(void);
#define __put_user_nocheck(x,ptr,size) \ #define __put_user_nocheck(x,ptr,size) \
({ \ ({ \
long __pu_err; \ long __pu_err; \
check_user_ptr(ptr); \
__put_user_size((x),(ptr),(size),__pu_err,-EFAULT); \ __put_user_size((x),(ptr),(size),__pu_err,-EFAULT); \
__pu_err; \ __pu_err; \
}) })
...@@ -123,7 +128,7 @@ extern long __put_user_bad(void); ...@@ -123,7 +128,7 @@ extern long __put_user_bad(void);
#define __put_user_check(x,ptr,size) \ #define __put_user_check(x,ptr,size) \
({ \ ({ \
long __pu_err = -EFAULT; \ long __pu_err = -EFAULT; \
__typeof__(*(ptr)) *__pu_addr = (ptr); \ void __user *__pu_addr = (ptr); \
if (access_ok(VERIFY_WRITE,__pu_addr,size)) \ if (access_ok(VERIFY_WRITE,__pu_addr,size)) \
__put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT); \ __put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT); \
__pu_err; \ __pu_err; \
...@@ -187,6 +192,7 @@ extern long __get_user_bad(void); ...@@ -187,6 +192,7 @@ extern long __get_user_bad(void);
do { \ do { \
might_sleep(); \ might_sleep(); \
retval = 0; \ retval = 0; \
check_user_ptr(ptr); \
switch (size) { \ switch (size) { \
case 1: __get_user_asm(x,ptr,retval,"lbz",errret); break; \ case 1: __get_user_asm(x,ptr,retval,"lbz",errret); break; \
case 2: __get_user_asm(x,ptr,retval,"lhz",errret); break; \ case 2: __get_user_asm(x,ptr,retval,"lhz",errret); break; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment