aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJann Horn <[email protected]>2019-03-29 22:46:49 +0100
committerBorislav Petkov <[email protected]>2019-04-03 11:43:49 +0200
commita0fe2c6479aab5723239b315ef1b552673f434a3 (patch)
tree31093171751e413002c3812a6fb1bacc5fc217c2
parent7dd47617114921fdd8c095509e5e7b4373cc44a1 (diff)
linux/kernel.h: Use parentheses around argument in u64_to_user_ptr()
Use parentheses around uses of the argument in u64_to_user_ptr() to ensure that the cast doesn't apply to part of the argument. There are existing uses of the macro of the form u64_to_user_ptr(A + B) which expands to (void __user *)(uintptr_t)A + B (the cast applies to the first operand of the addition, the addition is a pointer addition). This happens to still work as intended, the semantic difference doesn't cause a difference in behavior. But I want to use u64_to_user_ptr() with a ternary operator in the argument, like so: u64_to_user_ptr(A ? B : C) This currently doesn't work as intended. Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Mukesh Ojha <[email protected]> Cc: Andrei Vagin <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Kees Cook <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: NeilBrown <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Qiaowei Ren <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
-rw-r--r--include/linux/kernel.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 34a5036debd3..2d14e21c16c0 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -47,8 +47,8 @@
#define u64_to_user_ptr(x) ( \
{ \
- typecheck(u64, x); \
- (void __user *)(uintptr_t)x; \
+ typecheck(u64, (x)); \
+ (void __user *)(uintptr_t)(x); \
} \
)