lkml.org 
[lkml]   [2015]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3] asm-generic: {get,put}_user ptr argument evaluate only 1 time
Date
Current implemantation ptr argument evaluate 2 times.
It'll be an unexpected result.

Changes v3:
Some build error fix.
Changes v2:
Argument x protect.

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..d800a3f 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) \
({ \
+ uintptr_t __uip = (uintptr_t)(ptr); \
might_fault(); \
- access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \
- __put_user(x, ptr) : \
+ access_ok(VERIFY_WRITE, __uip, sizeof(*ptr)) ? \
+ __put_user((x), ((__typeof__(*ptr) *)__uip)) : \
-EFAULT; \
})

@@ -225,9 +226,10 @@ extern int __put_user_bad(void) __attribute__((noreturn));

#define get_user(x, ptr) \
({ \
+ uintptr_t __uip = (uintptr_t)(ptr); \
might_fault(); \
- access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \
- __get_user(x, ptr) : \
+ access_ok(VERIFY_READ, __uip, sizeof(*ptr)) ? \
+ __get_user((x), (__typeof__(*ptr) *)__uip) : \
-EFAULT; \
})

--
2.1.4


\
 
 \ /
  Last update: 2015-07-21 08:21    [W:0.122 / U:0.872 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site