[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250108090457.512198-22-bigeasy@linutronix.de>
Date: Wed, 8 Jan 2025 10:04:50 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: linux-modules@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Daniel Gomez <da.gomez@...sung.com>,
Luis Chamberlain <mcgrof@...nel.org>,
"Paul E . McKenney" <paulmck@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Petr Pavlu <petr.pavlu@...e.com>,
Sami Tolvanen <samitolvanen@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Elliot Berman <quic_eberman@...cinc.com>,
Kees Cook <kees@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>,
llvm@...ts.linux.dev,
Elliot Berman <elliot.berman@....qualcomm.com>
Subject: [PATCH v3 21/28] cfi: Use RCU while invoking __module_address().
__module_address() can be invoked within a RCU section, there is no
requirement to have preemption disabled.
The _notrace() variant was introduced in commit 14c4c8e41511a ("cfi: Use
rcu_read_{un}lock_sched_notrace"). The recursive case where
__cfi_slowpath_diag() could end up calling itself is no longer present,
as all that logic is gone since commit 89245600941e ("cfi: Switch to
-fsanitize=kcfi").
Sami Tolvanen said that KCFI checks don't perform function calls.
Elliot Berman verified it with
| modprobe -a dummy_stm stm_ftrace stm_p_basic
| mkdir -p /sys/kernel/config/stp-policy/dummy_stm.0.my-policy/default
| echo function > /sys/kernel/tracing/current_tracer
| echo 1 > /sys/kernel/tracing/tracing_on
| echo dummy_stm.0 > /sys/class/stm_source/ftrace/stm_source_link
Replace the rcu_read_lock_sched_notrace() section around
__module_address() with RCU.
Cc: Elliot Berman <quic_eberman@...cinc.com>
Cc: Kees Cook <kees@...nel.org>
Cc: Nathan Chancellor <nathan@...nel.org>
Cc: Sami Tolvanen <samitolvanen@...gle.com>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: llvm@...ts.linux.dev
Tested-by: Elliot Berman <elliot.berman@....qualcomm.com> # sm8650-qrd
Link: https://lore.kernel.org/all/20241230185812429-0800.eberman@hu-eberman-lv.qualcomm.com
Acked-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
---
kernel/cfi.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/kernel/cfi.c b/kernel/cfi.c
index 08caad7767176..abcd4d1f98eab 100644
--- a/kernel/cfi.c
+++ b/kernel/cfi.c
@@ -71,14 +71,11 @@ static bool is_module_cfi_trap(unsigned long addr)
struct module *mod;
bool found = false;
- rcu_read_lock_sched_notrace();
-
+ guard(rcu)();
mod = __module_address(addr);
if (mod)
found = is_trap(addr, mod->kcfi_traps, mod->kcfi_traps_end);
- rcu_read_unlock_sched_notrace();
-
return found;
}
#else /* CONFIG_MODULES */
--
2.47.1
Powered by blists - more mailing lists