Re: [PATCH] kprobes: avoid crash when rmmod/insmod modules after ftrace_disabled
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date: 2025-12-03 04:51:24
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date: 2025-12-03 04:51:24
On Wed, 3 Dec 2025 10:37:05 +0800 yebin [off-list ref] wrote:
quoted
quoted
quoted
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index ab8f9fc1f0d1..17d451553389 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c@@ -1104,6 +1104,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);This one, it should fix simply.I tested it and it can solve the problem. This is indeed a good solution that reuses the original code. Do you want me to send a new patch version according to your proposal?
OK, I'll send it with some tags which is required for this fix. Please add your tested-by on that. Thank you,
quoted
Thank you,quoted
quoted
-- Masami Hiramatsu (Google) [off-list ref]