Commit 881da224 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] ppc uaccess annotations

 - get_user() __gu_val should be unsigned long (same as with i386 patch)
 - __copy_to_user() et.al. didn't have proper type checking
 - documented the casts in __copy_tofrom_user() calls with __force.
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8f559333
......@@ -180,7 +180,8 @@ do { \
#define __get_user_nocheck(x, ptr, size) \
({ \
long __gu_err, __gu_val; \
long __gu_err; \
unsigned long __gu_val; \
__chk_user_ptr(ptr); \
__get_user_size(__gu_val, (ptr), (size), __gu_err); \
(x) = (__typeof__(*(ptr)))__gu_val; \
......@@ -199,7 +200,8 @@ do { \
#define __get_user_check(x, ptr, size) \
({ \
long __gu_err = -EFAULT, __gu_val = 0; \
long __gu_err = -EFAULT; \
unsigned long __gu_val = 0; \
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
if (access_ok(VERIFY_READ, __gu_addr, (size))) \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
......@@ -305,10 +307,10 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
unsigned long over;
if (access_ok(VERIFY_READ, from, n))
return __copy_tofrom_user((void __user *)to, from, n);
return __copy_tofrom_user((__force void __user *)to, from, n);
if ((unsigned long)from < TASK_SIZE) {
over = (unsigned long)from + n - TASK_SIZE;
return __copy_tofrom_user((void __user *)to, from, n - over) + over;
return __copy_tofrom_user((__force void __user *)to, from, n - over) + over;
}
return n;
}
......@@ -319,18 +321,24 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
unsigned long over;
if (access_ok(VERIFY_WRITE, to, n))
return __copy_tofrom_user(to, (void __user *) from, n);
return __copy_tofrom_user(to, (__force void __user *) from, n);
if ((unsigned long)to < TASK_SIZE) {
over = (unsigned long)to + n - TASK_SIZE;
return __copy_tofrom_user(to, (void __user *) from, n - over) + over;
return __copy_tofrom_user(to, (__force void __user *) from, n - over) + over;
}
return n;
}
#define __copy_from_user(to, from, size) \
__copy_tofrom_user((void __user *)(to), (from), (size))
#define __copy_to_user(to, from, size) \
__copy_tofrom_user((to), (void __user *)(from), (size))
static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long size)
{
return __copy_tofrom_user((__force void __user *)to, from, size);
}
static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long size)
{
return __copy_tofrom_user(to, (__force void __user *)from, size);
}
#define __copy_to_user_inatomic __copy_to_user
#define __copy_from_user_inatomic __copy_from_user
......
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