From nobody Fri Oct 2 01:56:12 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 4803A349CD1 for ; Thu, 6 Aug 2026 04:38:43 +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=1785991127; cv=none; b=jcZ/H4Us9ZAj1z1E9aQiM9NZNBG85uiYaIdaMKDA3qtKSxLxKZ8M9KgkQRORhJUuw5ZbxqLFTEwfubxcP4D5FoyHy2x1pg6i/th+LPc/aaz6xNXaKd07/38SRYIDrdAk4JXCumatiTGYOuZ8LvM73+s2pSto5Ya4mgJ9tETrTt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785991127; c=relaxed/simple; bh=a10big6dxlPiBpgvjZ6dRxJYd6o0maSLDu4dCdwyBwQ=; h=Cc:From:Message-Id:Subject:Mime-Version:Content-Type:To:Date; b=ECHc8XSwKbHjpjDJ8QOM+USMlNaUjmU9UGAUrFnTA6f98Lr2GqiR5ejMtq85O3zgMQ9WIe2p01Z6LruUze+uHRncez1Xn1MOdELMihnOwccDVeeMsZ7JO8AQBTXsIvo5zpB4NDgxTN2UtM36UlGgDWqLc3Pd0ckbnr1F/brikE0= 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=WmUAxrzL; 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="WmUAxrzL" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1785991108; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=0NvufHV1DuUnAobHZ+tPyaPHH4Nw9Y/cqmIEp6HhDP8=; b=WmUAxrzLMEaLhLtqaFVkkDFLd7NHkl6um58UZt7A4pzabEI9EyRHyKSzYB+PHYdgvg3qyu ZRnX7clRUUwBdNAdsAR8ed2y1qAn8RMLytCRt6DbwHLB7ulGDKyIpsJgbJPjnYlK4EYwoj F7VxdHRAod4JG8oY+iqr8tfkxf8xkh8K8ma07jiIgXcxwP15jNI0hOBJ5vm5mEyRM/q7sK MP9foYm1xKM6UYScJ+c5I31/FMdVezimem9844sU4DfVY6TxrABoNFvD/UtId/GkiJY0UM Gq1MZwwq0j0Qw+WenAFnB1T+8kPv+FPkusGoka2msyLPxbZ4AKs/eohUtUeLUA== Cc: "Alexandre Ghiti" , "Nam Cao" , "Thomas Gleixner" , "Zong Li" , "Ryan Roberts" , "Deepak Gupta" , , , "Rui Qi" From: "Rui Qi" Message-Id: <20260806043807.2583001-1-qirui.001@bytedance.com> Subject: [PATCH v2] riscv: kprobes: Prevent probes in breakpoint handlers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Original-From: Rui Qi To: "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" Date: Thu, 6 Aug 2026 12:38:07 +0800 X-Mailer: git-send-email 2.20.1 X-Lms-Return-Path: 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 --- 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 *r= egs) =20 return user ? uprobe_single_step_handler(regs) : kprobe_single_step_handl= er(regs); } +NOKPROBE_SYMBOL(probe_single_step_handler); =20 static bool probe_breakpoint_handler(struct pt_regs *regs) { @@ -276,6 +277,7 @@ static bool probe_breakpoint_handler(struct pt_regs *re= gs) =20 return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler= (regs); } +NOKPROBE_SYMBOL(probe_breakpoint_handler); =20 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); =20 asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *reg= s) { --=20 2.20.1