Skip to content

Commit

Permalink
perf probe: Fix event namelist to duplicate string
Browse files Browse the repository at this point in the history
Fix event namelist to duplicate string. Without duplicating, adding
multiple probes causes stack overwrite bug, because it reuses a
buffer on stack while the buffer is already added in the namelist.
String duplication solves this bug because only contents of the
buffer is copied to the namelist.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20091207170046.19230.55557.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Masami Hiramatsu authored and Ingo Molnar committed Dec 7, 2009
1 parent d56728b commit e1d2017
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,13 @@ static struct strlist *get_perf_event_names(int fd)

rawlist = get_trace_kprobe_event_rawlist(fd);

sl = strlist__new(false, NULL);
sl = strlist__new(true, NULL);
for (i = 0; i < strlist__nr_entries(rawlist); i++) {
ent = strlist__entry(rawlist, i);
parse_trace_kprobe_event(ent->s, &group, &event, NULL);
strlist__add(sl, event);
free(group);
free(event);
}

strlist__delete(rawlist);
Expand Down Expand Up @@ -480,5 +481,6 @@ void add_trace_kprobe_events(struct probe_point *probes, int nr_probes)
strlist__add(namelist, event);
}
}
strlist__delete(namelist);
close(fd);
}

0 comments on commit e1d2017

Please sign in to comment.