Commit 7263dda4 authored by H. Peter Anvin's avatar H. Peter Anvin

x86, smap: Handle csum_partial_copy_*_user()

Add SMAP annotations to csum_partial_copy_to/from_user().  These
functions legitimately access user space and thus need to set the AC
flag.

TODO: add explicit checks that the side with the kernel space pointer
really points into kernel space.
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
Link: http://lkml.kernel.org/n/tip-2aps0u00eer658fd5xyanan7@git.kernel.org
Cc: <stable@vger.kernel.org> # v3.7+
parent d8dfad38
...@@ -49,9 +49,15 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src, ...@@ -49,9 +49,15 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
int len, __wsum sum, int len, __wsum sum,
int *err_ptr) int *err_ptr)
{ {
__wsum ret;
might_sleep(); might_sleep();
return csum_partial_copy_generic((__force void *)src, dst, stac();
len, sum, err_ptr, NULL); ret = csum_partial_copy_generic((__force void *)src, dst,
len, sum, err_ptr, NULL);
clac();
return ret;
} }
/* /*
...@@ -176,10 +182,16 @@ static inline __wsum csum_and_copy_to_user(const void *src, ...@@ -176,10 +182,16 @@ static inline __wsum csum_and_copy_to_user(const void *src,
int len, __wsum sum, int len, __wsum sum,
int *err_ptr) int *err_ptr)
{ {
__wsum ret;
might_sleep(); might_sleep();
if (access_ok(VERIFY_WRITE, dst, len)) if (access_ok(VERIFY_WRITE, dst, len)) {
return csum_partial_copy_generic(src, (__force void *)dst, stac();
len, sum, NULL, err_ptr); ret = csum_partial_copy_generic(src, (__force void *)dst,
len, sum, NULL, err_ptr);
clac();
return ret;
}
if (len) if (len)
*err_ptr = -EFAULT; *err_ptr = -EFAULT;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <asm/checksum.h> #include <asm/checksum.h>
#include <linux/module.h> #include <linux/module.h>
#include <asm/smap.h>
/** /**
* csum_partial_copy_from_user - Copy and checksum from user space. * csum_partial_copy_from_user - Copy and checksum from user space.
...@@ -52,8 +53,10 @@ csum_partial_copy_from_user(const void __user *src, void *dst, ...@@ -52,8 +53,10 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
len -= 2; len -= 2;
} }
} }
stac();
isum = csum_partial_copy_generic((__force const void *)src, isum = csum_partial_copy_generic((__force const void *)src,
dst, len, isum, errp, NULL); dst, len, isum, errp, NULL);
clac();
if (unlikely(*errp)) if (unlikely(*errp))
goto out_err; goto out_err;
...@@ -82,6 +85,8 @@ __wsum ...@@ -82,6 +85,8 @@ __wsum
csum_partial_copy_to_user(const void *src, void __user *dst, csum_partial_copy_to_user(const void *src, void __user *dst,
int len, __wsum isum, int *errp) int len, __wsum isum, int *errp)
{ {
__wsum ret;
might_sleep(); might_sleep();
if (unlikely(!access_ok(VERIFY_WRITE, dst, len))) { if (unlikely(!access_ok(VERIFY_WRITE, dst, len))) {
...@@ -105,8 +110,11 @@ csum_partial_copy_to_user(const void *src, void __user *dst, ...@@ -105,8 +110,11 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
} }
*errp = 0; *errp = 0;
return csum_partial_copy_generic(src, (void __force *)dst, stac();
len, isum, NULL, errp); ret = csum_partial_copy_generic(src, (void __force *)dst,
len, isum, NULL, errp);
clac();
return ret;
} }
EXPORT_SYMBOL(csum_partial_copy_to_user); EXPORT_SYMBOL(csum_partial_copy_to_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