microblaze: fix copy_from_user()
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 9 Sep 2016 23:22:34 +0000 (19:22 -0400)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Feb 2017 22:32:58 +0000 (23:32 +0100)
commit d0cf385160c12abd109746cad1f13e3b3e8b50b8 upstream.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[wt: s/might_fault/might_sleep]

Signed-off-by: Willy Tarreau <w@1wt.eu>
arch/microblaze/include/asm/uaccess.h

index ef1c3400290a433504999b2aed36c8c7f6daf1ba..5488a1a71665899c8026549f3a08edc61d2f4f85 100644 (file)
@@ -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_sleep();
-       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)    \