diff options
author | Andrey Ryabinin <a.ryabinin@samsung.com> | 2014-05-07 08:07:25 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2014-07-11 13:33:36 +0100 |
commit | f85743e62e15955caa5da907f5a2b02b351722d3 (patch) | |
tree | 592a8c84406482484a60cd95ed18a06ad8848b87 /arch | |
parent | 502c1d6c3e8bbf4fd9152348ee65c439f37596b8 (diff) | |
download | lwn-f85743e62e15955caa5da907f5a2b02b351722d3.tar.gz lwn-f85743e62e15955caa5da907f5a2b02b351722d3.zip |
ARM: 8051/1: put_user: fix possible data corruption in put_user
commit 537094b64b229bf3ad146042f83e74cf6abe59df upstream.
According to arm procedure call standart r2 register is call-cloberred.
So after the result of x expression was put into r2 any following
function call in p may overwrite r2. To fix this, the result of p
expression must be saved to the temporary variable before the
assigment x expression to __r2.
Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/include/asm/uaccess.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 292c3f88f01d..18a285892bc4 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -158,8 +158,9 @@ extern int __put_user_8(void *, unsigned long long); #define put_user(x,p) \ ({ \ unsigned long __limit = current_thread_info()->addr_limit - 1; \ + const typeof(*(p)) __user *__tmp_p = (p); \ register const typeof(*(p)) __r2 asm("r2") = (x); \ - register const typeof(*(p)) __user *__p asm("r0") = (p);\ + register const typeof(*(p)) __user *__p asm("r0") = __tmp_p; \ register unsigned long __l asm("r1") = __limit; \ register int __e asm("r0"); \ switch (sizeof(*(__p))) { \ |