aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/include
diff options
context:
space:
mode:
authorAKASHI Takahiro <takahiro.akashi@linaro.org>2013-09-24 05:00:50 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2013-09-25 11:42:21 -0400
commit1f65c13efef69b6dc908e588f91a133641d8475c (patch)
treea0d11a91b177acb70c29643b426e9c6834930f68 /arch/arm64/include
parent25804e6a96681d5d2142058948e218999e4f547c (diff)
arm64: avoid multiple evaluation of ptr in get_user/put_user()
get_user() is defined as a function macro in arm64, and trace_get_user() calls it as followed: get_user(ch, ptr++); Since the second parameter occurs twice in the definition, 'ptr++' is unexpectedly evaluated twice and trace_get_user() will generate a bogus string from user-provided one. As a result, some ftrace sysfs operations, like "echo FUNCNAME > set_ftrace_filter," hit this case and eventually fail. This patch fixes the issue both in get_user() and put_user(). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> [catalin.marinas@arm.com: added __user type annotation and s/optr/__p/] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/include')
-rw-r--r--arch/arm64/include/asm/uaccess.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index edb3d5c73a32..7ecc2b23882e 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -166,9 +166,10 @@ do { \
166 166
167#define get_user(x, ptr) \ 167#define get_user(x, ptr) \
168({ \ 168({ \
169 __typeof__(*(ptr)) __user *__p = (ptr); \
169 might_fault(); \ 170 might_fault(); \
170 access_ok(VERIFY_READ, (ptr), sizeof(*(ptr))) ? \ 171 access_ok(VERIFY_READ, __p, sizeof(*__p)) ? \
171 __get_user((x), (ptr)) : \ 172 __get_user((x), __p) : \
172 ((x) = 0, -EFAULT); \ 173 ((x) = 0, -EFAULT); \
173}) 174})
174 175
@@ -227,9 +228,10 @@ do { \
227 228
228#define put_user(x, ptr) \ 229#define put_user(x, ptr) \
229({ \ 230({ \
231 __typeof__(*(ptr)) __user *__p = (ptr); \
230 might_fault(); \ 232 might_fault(); \
231 access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr))) ? \ 233 access_ok(VERIFY_WRITE, __p, sizeof(*__p)) ? \
232 __put_user((x), (ptr)) : \ 234 __put_user((x), __p) : \
233 -EFAULT; \ 235 -EFAULT; \
234}) 236})
235 237