arm: don't zero in __copy_from_user_inatomic()/__copy_from_user()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 10 Sep 2016 20:44:03 +0000 (16:44 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 15 Sep 2016 23:51:56 +0000 (19:51 -0400)
adjust copy_from_user(), obviously

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/arm/include/asm/uaccess.h
arch/arm/lib/copy_from_user.S

index a93c0f99acf7767c680158cf96acef87d1f0da51..1f59ea051bab814132074b09f55d3a57c800a471 100644 (file)
@@ -533,11 +533,12 @@ __clear_user(void __user *addr, unsigned long n)
 
 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
 {
-       if (access_ok(VERIFY_READ, from, n))
-               n = __copy_from_user(to, from, n);
-       else /* security hole - plug it */
-               memset(to, 0, n);
-       return n;
+       unsigned long res = 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;
 }
 
 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
index 1512bebfbf1b18ad317648891385a24e93d1f35f..7a4b060490012dd29f8a6d9fb8e24dfa58896bd1 100644 (file)
@@ -98,12 +98,9 @@ ENDPROC(arm_copy_from_user)
        .pushsection .fixup,"ax"
        .align 0
        copy_abort_preamble
-       ldmfd   sp!, {r1, r2}
-       sub     r3, r0, r1
-       rsb     r1, r3, r2
-       str     r1, [sp]
-       bl      __memzero
-       ldr     r0, [sp], #4
+       ldmfd   sp!, {r1, r2, r3}
+       sub     r0, r0, r1
+       rsb     r0, r0, r2
        copy_abort_end
        .popsection