Commit a9ede5b3 authored by Mike Frysinger's avatar Mike Frysinger Committed by Arnd Bergmann

asm-generic: uaccess: fix up local access_ok() usage

There's no reason that I can see to use the short __access_ok() form
directly when the access_ok() is clearer in intent and for most people,
expands to the same C code (i.e. always specify the first field -- access
type).  Not all no-mmu systems lack memory protection, so the read/write
could feasibly be checked.
Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 9844813f
...@@ -163,7 +163,7 @@ static inline __must_check long __copy_to_user(void __user *to, ...@@ -163,7 +163,7 @@ static inline __must_check long __copy_to_user(void __user *to,
#define put_user(x, ptr) \ #define put_user(x, ptr) \
({ \ ({ \
might_sleep(); \ might_sleep(); \
__access_ok(ptr, sizeof (*ptr)) ? \ access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \
__put_user(x, ptr) : \ __put_user(x, ptr) : \
-EFAULT; \ -EFAULT; \
}) })
...@@ -219,7 +219,7 @@ extern int __put_user_bad(void) __attribute__((noreturn)); ...@@ -219,7 +219,7 @@ extern int __put_user_bad(void) __attribute__((noreturn));
#define get_user(x, ptr) \ #define get_user(x, ptr) \
({ \ ({ \
might_sleep(); \ might_sleep(); \
__access_ok(ptr, sizeof (*ptr)) ? \ access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \
__get_user(x, ptr) : \ __get_user(x, ptr) : \
-EFAULT; \ -EFAULT; \
}) })
...@@ -244,7 +244,7 @@ static inline long copy_from_user(void *to, ...@@ -244,7 +244,7 @@ static inline long copy_from_user(void *to,
const void __user * from, unsigned long n) const void __user * from, unsigned long n)
{ {
might_sleep(); might_sleep();
if (__access_ok(from, n)) if (access_ok(VERIFY_READ, from, n))
return __copy_from_user(to, from, n); return __copy_from_user(to, from, n);
else else
return n; return n;
...@@ -254,7 +254,7 @@ static inline long copy_to_user(void __user *to, ...@@ -254,7 +254,7 @@ static inline long copy_to_user(void __user *to,
const void *from, unsigned long n) const void *from, unsigned long n)
{ {
might_sleep(); might_sleep();
if (__access_ok(to, n)) if (access_ok(VERIFY_WRITE, to, n))
return __copy_to_user(to, from, n); return __copy_to_user(to, from, n);
else else
return n; return n;
...@@ -278,7 +278,7 @@ __strncpy_from_user(char *dst, const char __user *src, long count) ...@@ -278,7 +278,7 @@ __strncpy_from_user(char *dst, const char __user *src, long count)
static inline long static inline long
strncpy_from_user(char *dst, const char __user *src, long count) strncpy_from_user(char *dst, const char __user *src, long count)
{ {
if (!__access_ok(src, 1)) if (!access_ok(VERIFY_READ, src, 1))
return -EFAULT; return -EFAULT;
return __strncpy_from_user(dst, src, count); return __strncpy_from_user(dst, src, count);
} }
...@@ -318,7 +318,7 @@ static inline __must_check unsigned long ...@@ -318,7 +318,7 @@ static inline __must_check unsigned long
clear_user(void __user *to, unsigned long n) clear_user(void __user *to, unsigned long n)
{ {
might_sleep(); might_sleep();
if (!__access_ok(to, n)) if (!access_ok(VERIFY_WRITE, to, n))
return n; return n;
return __clear_user(to, n); return __clear_user(to, n);
......
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