[lkml]   [2022]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v2 1/1] context_tracking: Use arch_atomic_read() in __ct_state for KASAN
From: "Paul E. McKenney" <>

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.

Signed-off-by: Paul E. McKenney <>
Cc: Frederic Weisbecker <>
Cc: Marco Elver <>
Reviewed-by: Marco Elver <>
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 0aecc07fb4f5..81c51e5f0314 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;

 \ /
  Last update: 2022-06-23 00:52    [W:0.175 / U:0.692 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site