diff options
author | Yoshinori Sato <ysato@users.sourceforge.jp> | 2015-07-16 13:56:06 +0900 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2016-10-05 22:40:20 -0400 |
commit | a0ed243c99234b62e9b25871eda6374289e6d506 (patch) | |
tree | adf9a0b3a84515e9524e4630dfcf549d12ab4d76 | |
parent | 93e5a11e71677cabca6fb5e48acbccd2985d5b2d (diff) | |
download | lwn-a0ed243c99234b62e9b25871eda6374289e6d506.tar.gz lwn-a0ed243c99234b62e9b25871eda6374289e6d506.zip |
asm-generic: {get,put}_user ptr argument evaluate only 1 time
[ Upstream commit a02613a4ba679eacec8251976d02809d533fa717 ]
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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
-rw-r--r-- | include/asm-generic/uaccess.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index e8e50f69e3c6..04e21a41796a 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; \ }) |