Commit a7d02afe authored by Linus Torvalds's avatar Linus Torvalds

Make x86 user-copy have user pointer annotations to match

declarations.
parent 162132e0
...@@ -12,14 +12,16 @@ ...@@ -12,14 +12,16 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/mmx.h> #include <asm/mmx.h>
static inline int movsl_is_ok(const void *a1, const void *a2, unsigned long n) static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned long n)
{ {
#ifdef CONFIG_X86_INTEL_USERCOPY #ifdef CONFIG_X86_INTEL_USERCOPY
if (n >= 64 && (((const long)a1 ^ (const long)a2) & movsl_mask.mask)) if (n >= 64 && ((a1 ^ a2) & movsl_mask.mask))
return 0; return 0;
#endif #endif
return 1; return 1;
} }
#define movsl_is_ok(a1,a2,n) \
__movsl_is_ok((unsigned long)(a1),(unsigned long)(a2),(n))
/* /*
* Copy a null terminated string from userspace. * Copy a null terminated string from userspace.
...@@ -74,7 +76,7 @@ do { \ ...@@ -74,7 +76,7 @@ do { \
* and returns @count. * and returns @count.
*/ */
long long
__strncpy_from_user(char *dst, const char *src, long count) __strncpy_from_user(char *dst, const char __user *src, long count)
{ {
long res; long res;
__do_strncpy_from_user(dst, src, count, res); __do_strncpy_from_user(dst, src, count, res);
...@@ -100,7 +102,7 @@ __strncpy_from_user(char *dst, const char *src, long count) ...@@ -100,7 +102,7 @@ __strncpy_from_user(char *dst, const char *src, long count)
* and returns @count. * and returns @count.
*/ */
long long
strncpy_from_user(char *dst, const char *src, long count) strncpy_from_user(char *dst, const char __user *src, long count)
{ {
long res = -EFAULT; long res = -EFAULT;
if (access_ok(VERIFY_READ, src, 1)) if (access_ok(VERIFY_READ, src, 1))
...@@ -145,7 +147,7 @@ do { \ ...@@ -145,7 +147,7 @@ do { \
* On success, this will be zero. * On success, this will be zero.
*/ */
unsigned long unsigned long
clear_user(void *to, unsigned long n) clear_user(void __user *to, unsigned long n)
{ {
if (access_ok(VERIFY_WRITE, to, n)) if (access_ok(VERIFY_WRITE, to, n))
__do_clear_user(to, n); __do_clear_user(to, n);
...@@ -164,7 +166,7 @@ clear_user(void *to, unsigned long n) ...@@ -164,7 +166,7 @@ clear_user(void *to, unsigned long n)
* On success, this will be zero. * On success, this will be zero.
*/ */
unsigned long unsigned long
__clear_user(void *to, unsigned long n) __clear_user(void __user *to, unsigned long n)
{ {
__do_clear_user(to, n); __do_clear_user(to, n);
return n; return n;
...@@ -181,7 +183,7 @@ __clear_user(void *to, unsigned long n) ...@@ -181,7 +183,7 @@ __clear_user(void *to, unsigned long n)
* On exception, returns 0. * On exception, returns 0.
* If the string is too long, returns a value greater than @n. * If the string is too long, returns a value greater than @n.
*/ */
long strnlen_user(const char *s, long n) long strnlen_user(const char __user *s, long n)
{ {
unsigned long mask = -__addr_ok(s); unsigned long mask = -__addr_ok(s);
unsigned long res, tmp; unsigned long res, tmp;
...@@ -484,7 +486,7 @@ do { \ ...@@ -484,7 +486,7 @@ do { \
} while (0) } while (0)
unsigned long __copy_to_user_ll(void *to, const void *from, unsigned long n) unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned long n)
{ {
#ifndef CONFIG_X86_WP_WORKS_OK #ifndef CONFIG_X86_WP_WORKS_OK
if (unlikely(boot_cpu_data.wp_works_ok == 0) && if (unlikely(boot_cpu_data.wp_works_ok == 0) &&
...@@ -534,17 +536,17 @@ unsigned long __copy_to_user_ll(void *to, const void *from, unsigned long n) ...@@ -534,17 +536,17 @@ unsigned long __copy_to_user_ll(void *to, const void *from, unsigned long n)
} }
#endif #endif
if (movsl_is_ok(to, from, n)) if (movsl_is_ok(to, from, n))
__copy_user(to, from, n); __copy_user((void *)to, from, n);
else else
n = __copy_user_intel(to, from, n); n = __copy_user_intel((void *)to, from, n);
return n; return n;
} }
unsigned long __copy_from_user_ll(void *to, const void *from, unsigned long n) unsigned long __copy_from_user_ll(void *to, const void __user *from, unsigned long n)
{ {
if (movsl_is_ok(to, from, n)) if (movsl_is_ok(to, from, n))
__copy_user_zeroing(to, from, n); __copy_user_zeroing(to, (const void *) from, n);
else else
n = __copy_user_zeroing_intel(to, from, n); n = __copy_user_zeroing_intel(to, (const void *) from, n);
return n; return 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