arm64: don't zero in __copy_from_user{,_inatomic}
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 10 Sep 2016 20:50:00 +0000 (16:50 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 15 Sep 2016 23:51:56 +0000 (19:51 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/arm64/include/asm/uaccess.h
arch/arm64/lib/copy_from_user.S

index c47257c..bcaf6fb 100644 (file)
@@ -278,14 +278,16 @@ static inline unsigned long __must_check __copy_to_user(void __user *to, const v
 
 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
 {
+       unsigned long res = n;
        kasan_check_write(to, n);
 
        if (access_ok(VERIFY_READ, from, n)) {
                check_object_size(to, n, false);
-               n = __arch_copy_from_user(to, from, n);
-       } else /* security hole - plug it */
-               memset(to, 0, n);
-       return n;
+               res = __arch_copy_from_user(to, from, n);
+       }
+       if (unlikely(res))
+               memset(to + (n - res), 0, res);
+       return res;
 }
 
 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
index 0b90497..4fd67ea 100644 (file)
@@ -79,11 +79,6 @@ ENDPROC(__arch_copy_from_user)
 
        .section .fixup,"ax"
        .align  2
-9998:
-       sub     x0, end, dst
-9999:
-       strb    wzr, [dst], #1                  // zero remaining buffer space
-       cmp     dst, end
-       b.lo    9999b
+9998:  sub     x0, end, dst                    // bytes not copied
        ret
        .previous