lkml.org 
[lkml]   [2021]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [GIT PULL] tracing/uprobe: Fix uprobe_perf_open probes iteration
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
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);
\
 
 \ /
  Last update: 2021-11-24 19:28    [W:0.051 / U:1.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site