diff options
author | Yongqin Liu <yongqin.liu@linaro.org> | 2013-05-22 18:02:55 +0200 |
---|---|---|
committer | Bernhard Rosenkränzer <bero@lindev.ch> | 2013-07-18 20:49:00 +0200 |
commit | f5f81853bdc8aa74e265648b67bab50ab148c4da (patch) | |
tree | 579a0f0e7058b633aa49bbb4ffb831c15131dcf6 | |
parent | 617fe8997c4eb497525c7def9f6a8ba329d35000 (diff) |
arm64: uaccess.h: Fix get_user macro to evaluate passed in expressions before using them
The arm64 get_user macro does not evaluate expressions before using them
multiple times. This can cause problems if an expression with
side-effects like p++ is passed in as an argument, as we'll end up
incrementing p multiple times. Thus to fix this, we evaluate the
expression once and store it in a variable before using it as needed.
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rw-r--r-- | arch/arm64/include/asm/uaccess.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 008f8481da6..900658d25a8 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -166,9 +166,10 @@ do { \ #define get_user(x, ptr) \ ({ \ + const __typeof__(*(ptr)) __user *__p = (ptr);\ might_sleep(); \ - access_ok(VERIFY_READ, (ptr), sizeof(*(ptr))) ? \ - __get_user((x), (ptr)) : \ + access_ok(VERIFY_READ, (__p), sizeof(*(__p))) ? \ + __get_user((x), (__p)) : \ ((x) = 0, -EFAULT); \ }) |