diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-03-19 22:07:21 +0300 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-03-29 01:23:29 +0300 |
commit | 07f78b308984042dde424191ab8f3237bcf6a0d1 (patch) | |
tree | f880c01d0cc055995c5dec7b02efbd56fd2b6755 /arch/cris | |
parent | a8be34459ca92d4f1034921bffd09df5441938be (diff) | |
download | linux-07f78b308984042dde424191ab8f3237bcf6a0d1.tar.xz |
cris: don't rely upon __copy_user_zeroing() zeroing the tail
we want to get rid of it; unfortunately, it's tangled as hell, so
it'll take many steps, more's the pity.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/cris')
-rw-r--r-- | arch/cris/include/asm/uaccess.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h index f62f546720a9..c8858e15d709 100644 --- a/arch/cris/include/asm/uaccess.h +++ b/arch/cris/include/asm/uaccess.h @@ -338,14 +338,16 @@ static inline size_t clear_user(void __user *to, size_t n) static inline size_t copy_from_user(void *to, const void __user *from, size_t n) { - if (unlikely(!access_ok(VERIFY_READ, from, n))) { - memset(to, 0, n); - return n; + size_t res = n; + if (likely(access_ok(VERIFY_READ, from, n))) { + if (__builtin_constant_p(n)) + res = __constant_copy_from_user(to, from, n); + else + res = __copy_user_zeroing(to, from, n); } - if (__builtin_constant_p(n)) - return __constant_copy_from_user(to, from, n); - else - return __copy_user_zeroing(to, from, n); + if (unlikely(res)) + memset(to + n - res , 0, res); + return res; } static inline size_t copy_to_user(void __user *to, const void *from, size_t n) |