mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] riscv: kprobes: Prevent probes in breakpoint handlers
@ 2026-08-06  4:38 Rui Qi
  2026-08-06 17:02 ` Paul Walmsley
  0 siblings, 1 reply; 2+ messages in thread
From: Rui Qi @ 2026-08-06  4:38 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou
  Cc: Alexandre Ghiti, Nam Cao, Thomas Gleixner, Zong Li, Ryan Roberts,
	Deepak Gupta, linux-riscv, linux-kernel, Rui Qi

The ftrace selftest multiple_kprobes.tc registers kprobe events on
the first 256 text symbols from /proc/kallsyms. If handle_break() is
selected as a probe target on RISC-V, the breakpoint exception path
can trap again before it reaches the kprobe breakpoint handler. That
recursively enters do_trap_break() and can make the system
unresponsive.

Mark handle_break() and its local probe dispatch helpers as nokprobe
symbols so they are added to the kprobe blacklist, matching other
low-level breakpoint exception paths.

Signed-off-by: Rui Qi <qirui.001@bytedance.com>
Reviewed-by: Nam Cao <namcao@linutronix.de>
---
Changes in v2:
- Drop the blank line before NOKPROBE_SYMBOL() to match the local style.
- Add Nam's Reviewed-by tag.

 arch/riscv/kernel/traps.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index 2f57fd48ec28..f8292adda099 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -269,6 +269,7 @@ static bool probe_single_step_handler(struct pt_regs *regs)
 
 	return user ? uprobe_single_step_handler(regs) : kprobe_single_step_handler(regs);
 }
+NOKPROBE_SYMBOL(probe_single_step_handler);
 
 static bool probe_breakpoint_handler(struct pt_regs *regs)
 {
@@ -276,6 +277,7 @@ static bool probe_breakpoint_handler(struct pt_regs *regs)
 
 	return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler(regs);
 }
+NOKPROBE_SYMBOL(probe_breakpoint_handler);
 
 void handle_break(struct pt_regs *regs)
 {
@@ -300,6 +302,7 @@ void handle_break(struct pt_regs *regs)
 	else
 		die(regs, "Kernel BUG");
 }
+NOKPROBE_SYMBOL(handle_break);
 
 asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs)
 {
-- 
2.20.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] riscv: kprobes: Prevent probes in breakpoint handlers
  2026-08-06  4:38 [PATCH v2] riscv: kprobes: Prevent probes in breakpoint handlers Rui Qi
@ 2026-08-06 17:02 ` Paul Walmsley
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Walmsley @ 2026-08-06 17:02 UTC (permalink / raw)
  To: Rui Qi
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Nam Cao, Thomas Gleixner, Zong Li, Ryan Roberts, Deepak Gupta,
	linux-riscv, linux-kernel

On Thu, 6 Aug 2026, Rui Qi wrote:

> The ftrace selftest multiple_kprobes.tc registers kprobe events on
> the first 256 text symbols from /proc/kallsyms. If handle_break() is
> selected as a probe target on RISC-V, the breakpoint exception path
> can trap again before it reaches the kprobe breakpoint handler. That
> recursively enters do_trap_break() and can make the system
> unresponsive.
> 
> Mark handle_break() and its local probe dispatch helpers as nokprobe
> symbols so they are added to the kprobe blacklist, matching other
> low-level breakpoint exception paths.
> 
> Signed-off-by: Rui Qi <qirui.001@bytedance.com>
> Reviewed-by: Nam Cao <namcao@linutronix.de>

Thanks, queued for v7.3.


- Paul

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-06 17:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-06  4:38 [PATCH v2] riscv: kprobes: Prevent probes in breakpoint handlers Rui Qi
2026-08-06 17:02 ` Paul Walmsley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®