From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63049379EF7 for ; Tue, 17 Mar 2026 09:19:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773739179; cv=none; b=lCdb5Abe1B4R7ftqz4T5eg2xyWTXM1fQ30Zs+htGKkcx4J3l6BaU7nYH4U78jLiG7zUhW4xWTwiqQWn2adinuCIeXSrRRp70l43B151nVgObUPXaodo8R+hbBSBxTGR5M9UYi84qQWhz5yMcyU90zQRC4upb8HYxhhnTjYqOMcQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773739179; c=relaxed/simple; bh=4si563Fd8NVA4epKsHQHTUnYF/KM8avFCksysUUpHUo=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=SWBVtz1+LpxbNRTxptYCCGtFvxD4+E8XZ9GQOnBRtEWaVuHusk0F4h97iSX2jepQWLSvoPxyoV5RY84bF9R6h5Vc0wKPWx6F59NHjIwWsfhiVZL/xaV/8BzLKoVYJD5+SNFHAKBPUqPAw6C10YXiqyYXORE1MsyuN2hODYffH+g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bJ94C4Ly; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bJ94C4Ly" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D4C4C2BC9E; Tue, 17 Mar 2026 09:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773739178; bh=4si563Fd8NVA4epKsHQHTUnYF/KM8avFCksysUUpHUo=; h=Subject:To:Cc:From:Date:From; b=bJ94C4Lyh16sYrm8k2bEl+k6vLTcGLKKfKvxgEXCLFOhuEuVd6zvV8q3SvhZfS+pG hkGDHdRritDC4Ff4dV5bDaKBqZI8uFejhMPlcxLGyU6H+MMf0BHwDE+9EaZB8qoObz WNtb27DgGkc9vWBgEvR50VkRWTT/5yLjeAK+ncnY= Subject: FAILED: patch "[PATCH] kprobes: avoid crash when rmmod/insmod after ftrace killed" failed to apply to 5.15-stable tree To: mhiramat@kernel.org,rostedt@goodmis.org,yebin10@huawei.com Cc: From: Date: Tue, 17 Mar 2026 10:19:28 +0100 Message-ID: <2026031728-emblem-wipe-1ce0@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x e113f0b46d19626ec15388bcb91432c9a4fd6261 # git commit -s git send-email --to '' --in-reply-to '2026031728-emblem-wipe-1ce0@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From e113f0b46d19626ec15388bcb91432c9a4fd6261 Mon Sep 17 00:00:00 2001 From: "Masami Hiramatsu (Google)" Date: Fri, 13 Mar 2026 23:14:14 +0900 Subject: [PATCH] kprobes: avoid crash when rmmod/insmod after ftrace killed After we hit ftrace is killed by some errors, the kernel crash if we remove modules in which kprobe probes. BUG: unable to handle page fault for address: fffffbfff805000d PGD 817fcc067 P4D 817fcc067 PUD 817fc8067 PMD 101555067 PTE 0 Oops: Oops: 0000 [#1] SMP KASAN PTI CPU: 4 UID: 0 PID: 2012 Comm: rmmod Tainted: G W OE Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE RIP: 0010:kprobes_module_callback+0x89/0x790 RSP: 0018:ffff88812e157d30 EFLAGS: 00010a02 RAX: 1ffffffff805000d RBX: dffffc0000000000 RCX: ffffffff86a8de90 RDX: ffffed1025c2af9b RSI: 0000000000000008 RDI: ffffffffc0280068 RBP: 0000000000000000 R08: 0000000000000001 R09: ffffed1025c2af9a R10: ffff88812e157cd7 R11: 205d323130325420 R12: 0000000000000002 R13: ffffffffc0290488 R14: 0000000000000002 R15: ffffffffc0280040 FS: 00007fbc450dd740(0000) GS:ffff888420331000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: fffffbfff805000d CR3: 000000010f624000 CR4: 00000000000006f0 Call Trace: notifier_call_chain+0xc6/0x280 blocking_notifier_call_chain+0x60/0x90 __do_sys_delete_module.constprop.0+0x32a/0x4e0 do_syscall_64+0x5d/0xfa0 entry_SYSCALL_64_after_hwframe+0x76/0x7e This is because the kprobe on ftrace does not correctly handles the kprobe_ftrace_disabled flag set by ftrace_kill(). To prevent this error, check kprobe_ftrace_disabled in __disarm_kprobe_ftrace() and skip all ftrace related operations. Link: https://lore.kernel.org/all/176473947565.1727781.13110060700668331950.stgit@mhiramat.tok.corp.google.com/ Reported-by: Ye Bin Closes: https://lore.kernel.org/all/20251125020536.2484381-1-yebin@huaweicloud.com/ Fixes: ae6aa16fdc16 ("kprobes: introduce ftrace based optimization") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) Acked-by: Steven Rostedt (Google) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index ab25b4aa9095..025af57ad3ed 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1178,6 +1178,10 @@ static int __disarm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops, int ret; lockdep_assert_held(&kprobe_mutex); + if (unlikely(kprobe_ftrace_disabled)) { + /* Now ftrace is disabled forever, disarm is already done. */ + return 0; + } if (*cnt == 1) { ret = unregister_ftrace_function(ops);