From nobody Fri Oct 2 07:46:35 2026 Received: from va-1-115.ptr.blmpb.com (va-1-115.ptr.blmpb.com [209.127.230.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59D1141D4C1 for ; Tue, 4 Aug 2026 06:44:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.115 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785825856; cv=none; b=HrxWyHHXcPVRY3UZ+8egmhSAq7C/JriDYcTW4ZhW4FQfS24qhA5QLqCPD6skrm9mPCmPYAo5WHyd4U+6w2hM1g4AhxouwixH14DbOkNQNjl0I282l45pK3BETIXdZpQrv4rktKntRpJ5YEY5jZammKUP3IDUNY9gnmTZzkgJ34s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785825856; c=relaxed/simple; bh=4kxKAp2bpvZA9PYhEJDgVJA5uiBtXpgFgcpGjnbNC/A=; h=To:Cc:Mime-Version:Date:Message-Id:Subject:Content-Type:From; b=D1rMLRzaHWfhBD5T3MuZas962mBh/q+b0DWIM/sxD90djVm7NjZWFjZ9s6AyGZ6IQNQzWdANaUIQmp6ZJWyeeOZXGmNXJ1auIvoMjaHb559+lvUS0onfkh4P3BXNFk/F+zflL3cu8bcDEkJvyK3lSKvU5PKci+qBYj5FVL4Mvyw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=AoH2goO1; arc=none smtp.client-ip=209.127.230.115 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="AoH2goO1" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1785825843; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=WIsLlus2jsqnby9mK4MdBDvjpnF7QpuhWuL6ZpAFUso=; b=AoH2goO1jyLpzUYKB+6wtce1xh2JYhJXVsbOCl2ECrVliu+7RjSZtzm100aiMwy8q7syFl V1M7RJMNrDTeurV2cN0Zp4vjDcJvu4XqCeLPcJfuzG5C5Si0WFex4gfsUQXbzowT3HI1hY VXJGR2AhKcWYeG64bF+8ZPDoVP5Ftao7/NX2GROzqMGoxc8C/pv9I/LUx52dRmpPyPw6Un 3uGG09hTfi+gOBI0FtDrxUMSSU+V9V3tnrLGXBoQYaBsYFN62p1VGS5dTkxjApkHYdh/72 G78jP9shK6RbSj3W9U8YXvBAEWITMrni8KRhhXY6aA51d957Ya9tcBKWSAvu/w== To: Cc: "Rui Qi" , "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" , "Alexandre Ghiti" , "Thomas Gleixner" , "Zong Li" , "Conor Dooley" , "Nam Cao" , "Lukas Gerlach" , "Deepak Gupta" , "Ryan Roberts" , Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Lms-Return-Path: X-Original-From: Rui Qi Date: Tue, 4 Aug 2026 14:43:41 +0800 Message-Id: <20260804064343.1865283-1-qirui.001@bytedance.com> Content-Transfer-Encoding: quoted-printable Subject: [PATCH] riscv: kprobes: Prevent probes in breakpoint handlers X-Mailer: git-send-email 2.20.1 From: "Rui Qi" Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Nam Cao --- arch/riscv/kernel/traps.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 2f57fd48ec28..5eb5785874dd 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -270,6 +270,8 @@ static bool probe_single_step_handler(struct pt_regs *r= egs) return user ? uprobe_single_step_handler(regs) : kprobe_single_step_handl= er(regs); } =20 +NOKPROBE_SYMBOL(probe_single_step_handler); + static bool probe_breakpoint_handler(struct pt_regs *regs) { bool user =3D user_mode(regs); @@ -277,6 +279,8 @@ static bool probe_breakpoint_handler(struct pt_regs *re= gs) return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler= (regs); } =20 +NOKPROBE_SYMBOL(probe_breakpoint_handler); + void handle_break(struct pt_regs *regs) { if (probe_single_step_handler(regs)) @@ -301,6 +305,8 @@ void handle_break(struct pt_regs *regs) die(regs, "Kernel BUG"); } =20 +NOKPROBE_SYMBOL(handle_break); + asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *reg= s) { if (user_mode(regs)) { --=20 2.20.1