The following commit has been merged into the locking/kcsan branch of tip:

Commit-ID:     aa7d8a2ee1e9b80e36ce2aa0d817c14ab3e23157
Gitweb:        
https://git.kernel.org/tip/aa7d8a2ee1e9b80e36ce2aa0d817c14ab3e23157
Author:        Marco Elver <el...@google.com>
AuthorDate:    Thu, 21 May 2020 16:20:45 +02:00
Committer:     Borislav Petkov <b...@suse.de>
CommitterDate: Fri, 22 May 2020 15:24:21 +02:00

compiler.h: Avoid nested statement expression in data_race()

It appears that compilers have trouble with nested statement
expressions. Therefore, remove one level of statement expression nesting
from the data_race() macro. This will help avoiding potential problems
in the future as its usage increases.

Reported-by: Borislav Petkov <b...@suse.de>
Reported-by: Nathan Chancellor <natechancel...@gmail.com>
Signed-off-by: Marco Elver <el...@google.com>
Signed-off-by: Borislav Petkov <b...@suse.de>
Acked-by: Peter Zijlstra (Intel) <pet...@infradead.org>
Acked-by: Will Deacon <w...@kernel.org>
Tested-by: Nick Desaulniers <ndesaulni...@google.com>
Link: https://lkml.kernel.org/r/20200520221712.ga21...@zn.tnic
Link: https://lkml.kernel.org/r/20200521142047.169334-10-el...@google.com
---
 include/linux/compiler.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 7444f02..379a507 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -211,12 +211,12 @@ void ftrace_likely_update(struct ftrace_likely_data *f, 
int val,
  */
 #define data_race(expr)                                                        
\
 ({                                                                     \
-       __kcsan_disable_current();                                      \
-       ({                                                              \
-               __unqual_scalar_typeof(({ expr; })) __v = ({ expr; });  \
-               __kcsan_enable_current();                               \
-               __v;                                                    \
+       __unqual_scalar_typeof(({ expr; })) __v = ({                    \
+               __kcsan_disable_current();                              \
+               expr;                                                   \
        });                                                             \
+       __kcsan_enable_current();                                       \
+       __v;                                                            \
 })
 
 /*

Reply via email to