]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.118/linux-kernel.h-use-parentheses-around-argument-in-u6.patch
Drop nfc patches from older trees
[thirdparty/kernel/stable-queue.git] / releases / 4.14.118 / linux-kernel.h-use-parentheses-around-argument-in-u6.patch
CommitLineData
cc56f4cd
SL
1From 32489fba909859425b9646d36143e6d6c067d3fa Mon Sep 17 00:00:00 2001
2From: Jann Horn <jannh@google.com>
3Date: Fri, 29 Mar 2019 22:46:49 +0100
4Subject: linux/kernel.h: Use parentheses around argument in u64_to_user_ptr()
5
6[ Upstream commit a0fe2c6479aab5723239b315ef1b552673f434a3 ]
7
8Use parentheses around uses of the argument in u64_to_user_ptr() to
9ensure that the cast doesn't apply to part of the argument.
10
11There are existing uses of the macro of the form
12
13 u64_to_user_ptr(A + B)
14
15which expands to
16
17 (void __user *)(uintptr_t)A + B
18
19(the cast applies to the first operand of the addition, the addition
20is a pointer addition). This happens to still work as intended, the
21semantic difference doesn't cause a difference in behavior.
22
23But I want to use u64_to_user_ptr() with a ternary operator in the
24argument, like so:
25
26 u64_to_user_ptr(A ? B : C)
27
28This currently doesn't work as intended.
29
30Signed-off-by: Jann Horn <jannh@google.com>
31Signed-off-by: Borislav Petkov <bp@suse.de>
32Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
33Cc: Andrei Vagin <avagin@openvz.org>
34Cc: Andrew Morton <akpm@linux-foundation.org>
35Cc: Dan Carpenter <dan.carpenter@oracle.com>
36Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37Cc: "H. Peter Anvin" <hpa@zytor.com>
38Cc: Ingo Molnar <mingo@kernel.org>
39Cc: Jani Nikula <jani.nikula@intel.com>
40Cc: Kees Cook <keescook@chromium.org>
41Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
42Cc: NeilBrown <neilb@suse.com>
43Cc: Peter Zijlstra <peterz@infradead.org>
44Cc: Qiaowei Ren <qiaowei.ren@intel.com>
45Cc: Thomas Gleixner <tglx@linutronix.de>
46Cc: x86-ml <x86@kernel.org>
47Link: https://lkml.kernel.org/r/20190329214652.258477-1-jannh@google.com
48Signed-off-by: Sasha Levin <sashal@kernel.org>
49---
50 include/linux/kernel.h | 4 ++--
51 1 file changed, 2 insertions(+), 2 deletions(-)
52
53diff --git a/include/linux/kernel.h b/include/linux/kernel.h
54index 4b484ab9e1635..1c5469adaa85e 100644
55--- a/include/linux/kernel.h
56+++ b/include/linux/kernel.h
57@@ -72,8 +72,8 @@
58
59 #define u64_to_user_ptr(x) ( \
60 { \
61- typecheck(u64, x); \
62- (void __user *)(uintptr_t)x; \
63+ typecheck(u64, (x)); \
64+ (void __user *)(uintptr_t)(x); \
65 } \
66 )
67
68--
692.20.1
70