[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220628131619.2109651-21-frederic@kernel.org>
Date: Tue, 28 Jun 2022 15:16:19 +0200
From: Frederic Weisbecker <frederic@...nel.org>
To: "Paul E . McKenney" <paulmck@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Phil Auld <pauld@...hat.com>,
Alex Belits <abelits@...vell.com>,
Nicolas Saenz Julienne <nsaenz@...nel.org>,
Marco Elver <elver@...gle.com>,
Xiongfeng Wang <wangxiongfeng2@...wei.com>,
Neeraj Upadhyay <quic_neeraju@...cinc.com>,
Thomas Gleixner <tglx@...utronix.de>,
Nicolas Saenz Julienne <nsaenzju@...hat.com>,
Max Filippov <jcmvbkbc@...il.com>,
Frederic Weisbecker <frederic@...nel.org>,
Yu Liao <liaoyu15@...wei.com>,
Boqun Feng <boqun.feng@...il.com>,
Marcelo Tosatti <mtosatti@...hat.com>,
kernel test robot <lkp@...el.com>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Uladzislau Rezki <uladzislau.rezki@...y.com>,
Joel Fernandes <joel@...lfernandes.org>
Subject: [PATCH 20/20] context_tracking: Use arch_atomic_read() in __ct_state for KASAN
From: "Paul E. McKenney" <paulmck@...nel.org>
Context tracking's __ct_state() function can be invoked from noinstr state
where RCU is not watching. This means that its use of atomic_read()
causes KASAN to invoke the non-noinstr __kasan_check_read() function
from the noinstr function __ct_state(). This is problematic because
someone tracing the __kasan_check_read() function could get a nasty
surprise because of RCU not watching.
This commit therefore replaces the __ct_state() function's use of
atomic_read() with arch_atomic_read(), which KASAN does not attempt to
add instrumention to.
Reported-by: kernel test robot <lkp@...el.com>
Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
Cc: Frederic Weisbecker <frederic@...nel.org>
Cc: Marco Elver <elver@...gle.com>
Reviewed-by: Marco Elver <elver@...gle.com>
---
include/linux/context_tracking_state.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h
index e20a74bc0597..4a4d56f77180 100644
--- a/include/linux/context_tracking_state.h
+++ b/include/linux/context_tracking_state.h
@@ -49,7 +49,7 @@ DECLARE_PER_CPU(struct context_tracking, context_tracking);
static __always_inline int __ct_state(void)
{
- return atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK;
+ return arch_atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK;
}
#endif
--
2.25.1
Powered by blists - more mailing lists