diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-09-09 19:22:34 -0400 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2016-10-05 22:40:20 -0400 |
commit | d31b0dcfb1d1a6ca5b98d3605c5c5318cd9195a4 (patch) | |
tree | 916cd97cd4caf291cc7e7906f5651d5359105057 | |
parent | ba08781d8abc610e4094dacec31bbd3a87c506bd (diff) |
microblaze: fix copy_from_user()
[ Upstream commit d0cf385160c12abd109746cad1f13e3b3e8b50b8 ]
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
-rw-r--r-- | arch/microblaze/include/asm/uaccess.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h index 59a89a64a865..f983626a3c20 100644 --- a/arch/microblaze/include/asm/uaccess.h +++ b/arch/microblaze/include/asm/uaccess.h @@ -371,10 +371,13 @@ extern long __user_bad(void); 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); - 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; } #define __copy_to_user(to, from, n) \ |