Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1190040
| From | Yoshinori Sato <ysato@users.sourceforge.jp> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v4] asm-generic: {get,put}_user ptr argument evaluate only 1 time |
| Date | 2015-07-22 17:00 +0200 |
| Message-ID | <pP3F0-1wt-23@gated-at.bofh.it> (permalink) |
| References | <pMJKq-5my-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Current implemantation ptr argument evaluate 2 times.
It'll be an unexpected result.
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>
---
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..f02e696 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) \
({ \
+ const 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; \
})
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH v4] asm-generic: {get,put}_user ptr argument evaluate only 1 time Yoshinori Sato <ysato@users.sourceforge.jp> - 2015-07-22 17:00 +0200
Re: [PATCH v4] asm-generic: {get,put}_user ptr argument evaluate only 1 time David Howells <dhowells@redhat.com> - 2015-07-23 00:30 +0200
csiph-web