sh: fix copy_from_user()
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 22 Aug 2016 03:39:47 +0000 (23:39 -0400)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Feb 2017 22:33:01 +0000 (23:33 +0100)
commit 6e050503a150b2126620c1a1e9b3a368fcd51eac upstream.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Willy Tarreau <w@1wt.eu>
arch/sh/include/asm/uaccess.h

index 9486376605f4dc21c5c6a36f1a84df06810b8f28..c04cc18ae9cd65f75c4294d431335d312c711329 100644 (file)
@@ -151,7 +151,10 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
        __kernel_size_t __copy_size = (__kernel_size_t) n;
 
        if (__copy_size && __access_ok(__copy_from, __copy_size))
-               return __copy_user(to, from, __copy_size);
+               __copy_size = __copy_user(to, from, __copy_size);
+
+       if (unlikely(__copy_size))
+               memset(to + (n - __copy_size), 0, __copy_size);
 
        return __copy_size;
 }