public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] asm-generic: {get,put}_user ptr argument evaluate only 1 time
@ 2015-07-16  5:15 Yoshinori Sato
  2015-07-16  5:15 ` Yoshinori Sato
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Yoshinori Sato @ 2015-07-16  5:15 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch; +Cc: Yoshinori Sato, linux-kernel

Current implemantation ptr argument evaluate 2 times.
It'll be an unexpected result.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 include/asm-generic/uaccess.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 72d8803..1b813fb 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -163,9 +163,10 @@ static inline __must_check long __copy_to_user(void __user *to,
 
 #define put_user(x, ptr)					\
 ({								\
+	__typeof__((ptr)) __p = (ptr);				\
 	might_fault();						\
-	access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ?		\
-		__put_user(x, ptr) :				\
+	access_ok(VERIFY_WRITE, __p, sizeof(*__p)) ?		\
+		__put_user(x, __p) :				\
 		-EFAULT;					\
 })
 
@@ -225,9 +226,10 @@ extern int __put_user_bad(void) __attribute__((noreturn));
 
 #define get_user(x, ptr)					\
 ({								\
+	__typeof__((ptr)) __p = (ptr);				\
 	might_fault();						\
-	access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ?		\
-		__get_user(x, ptr) :				\
+	access_ok(VERIFY_READ, __p, sizeof(*__p)) ?		\
+		__get_user(x, __p) :				\
 		-EFAULT;					\
 })
 
-- 
2.1.4

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

end of thread, other threads:[~2015-07-23 17:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16  5:15 [PATCH] asm-generic: {get,put}_user ptr argument evaluate only 1 time Yoshinori Sato
2015-07-16  5:15 ` Yoshinori Sato
2015-07-16  6:40 ` Geert Uytterhoeven
2015-07-16  6:40   ` Geert Uytterhoeven
2015-07-16 13:33   ` Yoshinori Sato
2015-07-16 14:15 ` Arnd Bergmann
2015-07-17  3:27   ` Yoshinori Sato
2015-07-16 14:16 ` [PATCH v2] " Yoshinori Sato
2015-07-21  6:14 ` [PATCH v3] " Yoshinori Sato
2015-07-21 14:06   ` David Howells
2015-07-21 14:06     ` David Howells
2015-07-22  6:09     ` Yoshinori Sato
2015-07-22 14:52 ` [PATCH v4] " Yoshinori Sato
2015-07-22 22:24   ` David Howells
2015-07-22 22:24     ` David Howells
2015-07-23 17:55 ` [PATCH v5] " Yoshinori Sato

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