From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
stable@vger.kernel.org
Subject: [for-linus][PATCH 5/6] tracing/fprobe: Fix to check whether fprobe is registered correctly
Date: Sat, 05 Nov 2022 16:50:54 -0400 [thread overview]
Message-ID: <20221105205138.075774025@goodmis.org> (raw)
In-Reply-To: 20221105205049.462806482@goodmis.org
From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Since commit ab51e15d535e ("fprobe: Introduce FPROBE_FL_KPROBE_SHARED flag
for fprobe") introduced fprobe_kprobe_handler() for fprobe::ops::func,
unregister_fprobe() fails to unregister the registered if user specifies
FPROBE_FL_KPROBE_SHARED flag.
Moreover, __register_ftrace_function() is possible to change the
ftrace_ops::func, thus we have to check fprobe::ops::saved_func instead.
To check it correctly, it should confirm the fprobe::ops::saved_func is
either fprobe_handler() or fprobe_kprobe_handler().
Link: https://lore.kernel.org/all/166677683946.1459107.15997653945538644683.stgit@devnote3/
Fixes: cad9931f64dc ("fprobe: Add ftrace based probe APIs")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
kernel/trace/fprobe.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
index 71614b2a67ff..e8143e368074 100644
--- a/kernel/trace/fprobe.c
+++ b/kernel/trace/fprobe.c
@@ -303,7 +303,8 @@ int unregister_fprobe(struct fprobe *fp)
{
int ret;
- if (!fp || fp->ops.func != fprobe_handler)
+ if (!fp || (fp->ops.saved_func != fprobe_handler &&
+ fp->ops.saved_func != fprobe_kprobe_handler))
return -EINVAL;
/*
--
2.35.1
next prev parent reply other threads:[~2022-11-05 20:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-05 20:50 [for-linus][PATCH 0/6] tracing: Fixes for 6.1 Steven Rostedt
2022-11-05 20:50 ` [for-linus][PATCH 1/6] ring-buffer: Check for NULL cpu_buffer in ring_buffer_wake_waiters() Steven Rostedt
2022-11-05 20:50 ` [for-linus][PATCH 2/6] ftrace: Fix use-after-free for dynamic ftrace_ops Steven Rostedt
2022-11-05 20:50 ` [for-linus][PATCH 3/6] kprobe: reverse kp->flags when arm_kprobe failed Steven Rostedt
2022-11-05 20:50 ` [for-linus][PATCH 4/6] fprobe: Check rethook_alloc() return in rethook initialization Steven Rostedt
2022-11-05 20:50 ` Steven Rostedt [this message]
2022-11-05 20:50 ` [for-linus][PATCH 6/6] tracing: kprobe: Fix memory leak in test_gen_kprobe/kretprobe_cmd() Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221105205138.075774025@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox