* [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration
@ 2021-11-24 15:09 Steven Rostedt
2021-11-24 18:27 ` Linus Torvalds
2021-11-24 18:31 ` pr-tracker-bot
0 siblings, 2 replies; 6+ messages in thread
From: Steven Rostedt @ 2021-11-24 15:09 UTC (permalink / raw)
To: Linus Torvalds
Cc: LKML, Ingo Molnar, Andrew Morton, Jiri Olsa, Masami Hiramatsu
Linus,
tracing: Fix wrong uprobe variable in iterator
uprobe_perf_open() processes a list of probes, but due to a missing
setting of the uprobe to be processed, the loop processes the head probe
instead of the added probes.
Please pull the latest trace-v5.16-rc2 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v5.16-rc2
Tag SHA1: b035fc0d660c88f1ec940aba668d438c96ea1a5c
Head SHA1: 1880ed71ce863318c1ce93bf324876fb5f92854f
Jiri Olsa (1):
tracing/uprobe: Fix uprobe_perf_open probes iteration
----
kernel/trace/trace_uprobe.c | 1 +
1 file changed, 1 insertion(+)
---------------------------
commit 1880ed71ce863318c1ce93bf324876fb5f92854f
Author: Jiri Olsa <jolsa@redhat.com>
Date: Tue Nov 23 15:28:01 2021 +0100
tracing/uprobe: Fix uprobe_perf_open probes iteration
Add missing 'tu' variable initialization in the probes loop,
otherwise the head 'tu' is used instead of added probes.
Link: https://lkml.kernel.org/r/20211123142801.182530-1-jolsa@kernel.org
Cc: stable@vger.kernel.org
Fixes: 99c9a923e97a ("tracing/uprobe: Fix double perf_event linking on multiprobe uprobe")
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 0a5c0db3137e..f5f0039d31e5 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -1313,6 +1313,7 @@ static int uprobe_perf_open(struct trace_event_call *call,
return 0;
list_for_each_entry(pos, trace_probe_probe_list(tp), list) {
+ tu = container_of(pos, struct trace_uprobe, tp);
err = uprobe_apply(tu->inode, tu->offset, &tu->consumer, true);
if (err) {
uprobe_perf_close(call, event);
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration 2021-11-24 15:09 [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration Steven Rostedt @ 2021-11-24 18:27 ` Linus Torvalds 2021-11-24 18:30 ` Linus Torvalds 2021-11-24 18:33 ` Steven Rostedt 2021-11-24 18:31 ` pr-tracker-bot 1 sibling, 2 replies; 6+ messages in thread From: Linus Torvalds @ 2021-11-24 18:27 UTC (permalink / raw) To: Steven Rostedt Cc: LKML, Ingo Molnar, Andrew Morton, Jiri Olsa, Masami Hiramatsu [-- Attachment #1: Type: text/plain, Size: 1364 bytes --] On Wed, Nov 24, 2021 at 7:10 AM Steven Rostedt <rostedt@goodmis.org> wrote: > > tracing: Fix wrong uprobe variable in iterator I've pulled this, but: > list_for_each_entry(pos, trace_probe_probe_list(tp), list) { > + tu = container_of(pos, struct trace_uprobe, tp); honestly, the "list_for_each_entry()" followed by a "container_of()" like this makes me think you used the wrong entry to walk the list in. You actually don't want to ever use that struct trace_probe *pos; at all, and I think you should remove it. Instead, you should do something like list_for_each_entry(pu, trace_probe_probe_list(tp), tp.list) { ie simply walk the list _as_ the uprobe entry, not as some intermediate internal probe list entry only to convert to the uprobe. Now, I may be entirely off my meds here, and maybe there is something I'm missing, but I _think_ the attached patch should work, and avoid all that indirection through 'pos' that you don't care about and that seems to just have been a mistake. Feel free to call me funny names for when I missed some detail. Again - I *have* pulled your fix, and in fact the attached patch is relative to your fix. That fix isn't _wrong_. I just think it's a bit silly, and I think the cause of the bug in the first place was that unnecessary intermediate pointer. Linus [-- Attachment #2: patch.diff --] [-- Type: text/x-patch, Size: 1002 bytes --] kernel/trace/trace_uprobe.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index f5f0039d31e5..ee5408f2a68a 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -1300,7 +1300,7 @@ static int uprobe_perf_close(struct trace_event_call *call, static int uprobe_perf_open(struct trace_event_call *call, struct perf_event *event) { - struct trace_probe *pos, *tp; + struct trace_probe *tp; struct trace_uprobe *tu; int err = 0; @@ -1312,8 +1312,7 @@ static int uprobe_perf_open(struct trace_event_call *call, if (trace_uprobe_filter_add(tu->tp.event->filter, event)) return 0; - list_for_each_entry(pos, trace_probe_probe_list(tp), list) { - tu = container_of(pos, struct trace_uprobe, tp); + list_for_each_entry(tu, trace_probe_probe_list(tp), tp.list) { err = uprobe_apply(tu->inode, tu->offset, &tu->consumer, true); if (err) { uprobe_perf_close(call, event); ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration 2021-11-24 18:27 ` Linus Torvalds @ 2021-11-24 18:30 ` Linus Torvalds 2021-11-24 20:06 ` Jiri Olsa 2021-11-24 18:33 ` Steven Rostedt 1 sibling, 1 reply; 6+ messages in thread From: Linus Torvalds @ 2021-11-24 18:30 UTC (permalink / raw) To: Steven Rostedt Cc: LKML, Ingo Molnar, Andrew Morton, Jiri Olsa, Masami Hiramatsu On Wed, Nov 24, 2021 at 10:27 AM Linus Torvalds <torvalds@linux-foundation.org> wrote: > > Instead, you should do something like > > list_for_each_entry(pu, trace_probe_probe_list(tp), tp.list) { That 'pu' is a typo, it should be 'tu'. The patch itself got it right, I think. HOWEVER. Despite the patch itself getting it right, I want to point out that that was mostly by luck than anything else. The patch is ENTIRELY UNTESTED. Because that's how I roll, as you should all know by now. Linus ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration 2021-11-24 18:30 ` Linus Torvalds @ 2021-11-24 20:06 ` Jiri Olsa 0 siblings, 0 replies; 6+ messages in thread From: Jiri Olsa @ 2021-11-24 20:06 UTC (permalink / raw) To: Linus Torvalds Cc: Steven Rostedt, LKML, Ingo Molnar, Andrew Morton, Masami Hiramatsu On Wed, Nov 24, 2021 at 10:30:24AM -0800, Linus Torvalds wrote: > On Wed, Nov 24, 2021 at 10:27 AM Linus Torvalds > <torvalds@linux-foundation.org> wrote: > > > > Instead, you should do something like > > > > list_for_each_entry(pu, trace_probe_probe_list(tp), tp.list) { > > That 'pu' is a typo, it should be 'tu'. > > The patch itself got it right, I think. > > HOWEVER. Despite the patch itself getting it right, I want to point > out that that was mostly by luck than anything else. > > The patch is ENTIRELY UNTESTED. I put your patch to the test and.. it passed ;-) there are several other places like this around and also in trace_kprobe.c I can send the follow up fix tomorrow thanks, jirka > > Because that's how I roll, as you should all know by now. > > Linus > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration 2021-11-24 18:27 ` Linus Torvalds 2021-11-24 18:30 ` Linus Torvalds @ 2021-11-24 18:33 ` Steven Rostedt 1 sibling, 0 replies; 6+ messages in thread From: Steven Rostedt @ 2021-11-24 18:33 UTC (permalink / raw) To: Linus Torvalds Cc: LKML, Ingo Molnar, Andrew Morton, Jiri Olsa, Masami Hiramatsu On Wed, 24 Nov 2021 10:27:27 -0800 Linus Torvalds <torvalds@linux-foundation.org> wrote: > Now, I may be entirely off my meds here, and maybe there is something > I'm missing, but I _think_ the attached patch should work, and avoid > all that indirection through 'pos' that you don't care about and that > seems to just have been a mistake. > Masami and Jiri, This is your code. Would this be a legitimate clean up? -- Steve ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration 2021-11-24 15:09 [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration Steven Rostedt 2021-11-24 18:27 ` Linus Torvalds @ 2021-11-24 18:31 ` pr-tracker-bot 1 sibling, 0 replies; 6+ messages in thread From: pr-tracker-bot @ 2021-11-24 18:31 UTC (permalink / raw) To: Steven Rostedt Cc: Linus Torvalds, LKML, Ingo Molnar, Andrew Morton, Jiri Olsa, Masami Hiramatsu The pull request you sent on Wed, 24 Nov 2021 10:09:56 -0500: > git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git trace-v5.16-rc2 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/29889216befc1cee635da8a64f48caae47ffbcaf Thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-11-24 20:06 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-11-24 15:09 [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration Steven Rostedt 2021-11-24 18:27 ` Linus Torvalds 2021-11-24 18:30 ` Linus Torvalds 2021-11-24 20:06 ` Jiri Olsa 2021-11-24 18:33 ` Steven Rostedt 2021-11-24 18:31 ` pr-tracker-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox