public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] arm: put_user: fix possible data corruption in put_user
@ 2014-05-05  6:13 Andrey Ryabinin
  2014-05-05  9:01 ` Russell King - ARM Linux
  2014-05-05 14:15 ` Nicolas Pitre
  0 siblings, 2 replies; 8+ messages in thread
From: Andrey Ryabinin @ 2014-05-05  6:13 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 arch/arm/include/asm/uaccess.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 12c3a5d..4b584ac 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -171,8 +171,9 @@ extern int __put_user_8(void *, unsigned long long);
 #define __put_user_check(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))) {				\
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-05-07 13:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-05  6:13 [PATCH] arm: put_user: fix possible data corruption in put_user Andrey Ryabinin
2014-05-05  9:01 ` Russell King - ARM Linux
2014-05-05 10:50   ` Andrey Ryabinin
2014-05-05 13:45     ` Nicolas Pitre
2014-05-05 14:15 ` Nicolas Pitre
2014-05-06  7:11   ` [PATCHv2] " Andrey Ryabinin
2014-05-06 20:13     ` Nicolas Pitre
2014-05-07 13:19       ` Andrey Ryabinin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox