diff options
-rw-r--r-- | arch/arm/include/asm/uaccess.h | 11 | ||||
-rw-r--r-- | arch/arm/lib/copy_from_user.S | 9 |
2 files changed, 9 insertions, 11 deletions
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index a93c0f99acf7..1f59ea051bab 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h | |||
@@ -533,11 +533,12 @@ __clear_user(void __user *addr, unsigned long n) | |||
533 | 533 | ||
534 | static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n) | 534 | static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n) |
535 | { | 535 | { |
536 | if (access_ok(VERIFY_READ, from, n)) | 536 | unsigned long res = n; |
537 | n = __copy_from_user(to, from, n); | 537 | if (likely(access_ok(VERIFY_READ, from, n))) |
538 | else /* security hole - plug it */ | 538 | res = __copy_from_user(to, from, n); |
539 | memset(to, 0, n); | 539 | if (unlikely(res)) |
540 | return n; | 540 | memset(to + (n - res), 0, res); |
541 | return res; | ||
541 | } | 542 | } |
542 | 543 | ||
543 | static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n) | 544 | static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n) |
diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S index 1512bebfbf1b..7a4b06049001 100644 --- a/arch/arm/lib/copy_from_user.S +++ b/arch/arm/lib/copy_from_user.S | |||
@@ -98,12 +98,9 @@ ENDPROC(arm_copy_from_user) | |||
98 | .pushsection .fixup,"ax" | 98 | .pushsection .fixup,"ax" |
99 | .align 0 | 99 | .align 0 |
100 | copy_abort_preamble | 100 | copy_abort_preamble |
101 | ldmfd sp!, {r1, r2} | 101 | ldmfd sp!, {r1, r2, r3} |
102 | sub r3, r0, r1 | 102 | sub r0, r0, r1 |
103 | rsb r1, r3, r2 | 103 | rsb r0, r0, r2 |
104 | str r1, [sp] | ||
105 | bl __memzero | ||
106 | ldr r0, [sp], #4 | ||
107 | copy_abort_end | 104 | copy_abort_end |
108 | .popsection | 105 | .popsection |
109 | 106 | ||