summaryrefslogtreecommitdiff
path: root/include/asm-generic
diff options
context:
space:
mode:
authorAlex Shi <alex.shi@linaro.org>2016-10-05 13:21:50 +0200
committerAlex Shi <alex.shi@linaro.org>2016-10-05 13:21:50 +0200
commit10fd238c91a8dd2fb9c9bce99eb4d357254fb3c6 (patch)
tree7c24d0606e1183d104bd183ae5578a958e00fa34 /include/asm-generic
parente4f4f9e5b9ec7278b8384ea000c79325846a3872 (diff)
parent8d5e93bb8c9c48ee5948f6b1aff0e895381f09e6 (diff)
Merge remote-tracking branch 'lts/linux-4.4.y' into linux-linaro-lsk-v4.4
Conflicts: resovle the conflict on pax_copy for arch/ia64/include/asm/uaccess.h arch/powerpc/include/asm/uaccess.h arch/sparc/include/asm/uaccess_32.h
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/uaccess.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 1bfa602958f2..32901d11f8c4 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -230,14 +230,18 @@ extern int __put_user_bad(void) __attribute__((noreturn));
might_fault(); \
access_ok(VERIFY_READ, __p, sizeof(*ptr)) ? \
__get_user((x), (__typeof__(*(ptr)) *)__p) : \
- -EFAULT; \
+ ((x) = (__typeof__(*(ptr)))0,-EFAULT); \
})
#ifndef __get_user_fn
static inline int __get_user_fn(size_t size, const void __user *ptr, void *x)
{
- size = __copy_from_user(x, ptr, size);
- return size ? -EFAULT : size;
+ size_t n = __copy_from_user(x, ptr, size);
+ if (unlikely(n)) {
+ memset(x + (size - n), 0, n);
+ return -EFAULT;
+ }
+ return 0;
}
#define __get_user_fn(sz, u, k) __get_user_fn(sz, u, k)
@@ -257,11 +261,13 @@ extern int __get_user_bad(void) __attribute__((noreturn));
static inline long copy_from_user(void *to,
const void __user * from, unsigned long n)
{
+ unsigned long res = n;
might_fault();
- if (access_ok(VERIFY_READ, from, n))
- return __copy_from_user(to, from, n);
- else
- return n;
+ if (likely(access_ok(VERIFY_READ, from, n)))
+ res = __copy_from_user(to, from, n);
+ if (unlikely(res))
+ memset(to + (n - res), 0, res);
+ return res;
}
static inline long copy_to_user(void __user *to,