summaryrefslogtreecommitdiffstats
path: root/include/asm-generic/uaccess.h
diff options
context:
space:
mode:
authorYoshinori Sato <ysato@users.sourceforge.jp>2015-07-16 13:56:06 +0900
committerYoshinori Sato <ysato@users.sourceforge.jp>2015-11-08 22:44:42 +0900
commita02613a4ba679eacec8251976d02809d533fa717 (patch)
tree90d5aabd15bee0954437bcf96b4c13e0901e63e7 /include/asm-generic/uaccess.h
parenta795239b698d3f7c455b7f8841f5c62d20eefb23 (diff)
downloadop-kernel-dev-a02613a4ba679eacec8251976d02809d533fa717.zip
op-kernel-dev-a02613a4ba679eacec8251976d02809d533fa717.tar.gz
asm-generic: {get,put}_user ptr argument evaluate only 1 time
Current implemantation ptr argument evaluate 2 times. It'll be an unexpected result. Changes v5: Remove unnecessary const. Changes v4: Temporary pointer type change to const void* Changes v3: Some build error fix. Changes v2: Argument x protect. Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Diffstat (limited to 'include/asm-generic/uaccess.h')
-rw-r--r--include/asm-generic/uaccess.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 72d8803..1bfa602 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) \
({ \
+ void *__p = (ptr); \
might_fault(); \
- access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \
- __put_user(x, ptr) : \
+ access_ok(VERIFY_WRITE, __p, sizeof(*ptr)) ? \
+ __put_user((x), ((__typeof__(*(ptr)) *)__p)) : \
-EFAULT; \
})
@@ -225,9 +226,10 @@ extern int __put_user_bad(void) __attribute__((noreturn));
#define get_user(x, ptr) \
({ \
+ const void *__p = (ptr); \
might_fault(); \
- access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \
- __get_user(x, ptr) : \
+ access_ok(VERIFY_READ, __p, sizeof(*ptr)) ? \
+ __get_user((x), (__typeof__(*(ptr)) *)__p) : \
-EFAULT; \
})
OpenPOWER on IntegriCloud