]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
kcsan: Change data_race() to no longer require marking racing accesses
authorMarco Elver <elver@google.com>
Tue, 31 Mar 2020 19:32:33 +0000 (21:32 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 14 Apr 2020 00:18:15 +0000 (17:18 -0700)
Thus far, accesses marked with data_race() would still require the
racing access to be marked in some way (be it with READ_ONCE(),
WRITE_ONCE(), or data_race() itself), as otherwise KCSAN would still
report a data race.  This requirement, however, seems to be unintuitive,
and some valid use-cases demand *not* marking other accesses, as it
might hide more serious bugs (e.g. diagnostic reads).

Therefore, this commit changes data_race() to no longer require marking
racing accesses (although it's still recommended if possible).

The alternative would have been introducing another variant of
data_race(), however, since usage of data_race() already needs to be
carefully reasoned about, distinguishing between these cases likely adds
more complexity in the wrong place.

Link: https://lkml.kernel.org/r/20200331131002.GA30975@willie-the-truck
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Qian Cai <cai@lca.pw>
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
include/linux/compiler.h

index f504edebd5d7156f745e539217b0bf4419b9bbc6..1729bd17e9b78128ea289235c2bd8c0aef9e9655 100644 (file)
@@ -326,9 +326,9 @@ unsigned long read_word_at_a_time(const void *addr)
 #define data_race(expr)                                                        \
        ({                                                                     \
                typeof(({ expr; })) __val;                                     \
-               kcsan_nestable_atomic_begin();                                 \
+               kcsan_disable_current();                                       \
                __val = ({ expr; });                                           \
-               kcsan_nestable_atomic_end();                                   \
+               kcsan_enable_current();                                        \
                __val;                                                         \
        })
 #else