From: Masami Hiramatsu Date: Mon, 7 Dec 2009 17:00:46 +0000 (-0500) Subject: perf probe: Fix event namelist to duplicate string X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e1d2017b24fb31602f1128e6a8b2afc54c9283cd;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git perf probe: Fix event namelist to duplicate string 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 Cc: systemtap Cc: DLE Cc: Frederic Weisbecker Cc: Arnaldo Carvalho de Melo Cc: Frederic Weisbecker LKML-Reference: <20091207170046.19230.55557.stgit@dhcp-100-2-132.bos.redhat.com> Signed-off-by: Ingo Molnar --- diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index cd7fbda5e2a5..de0d91385c91 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -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); @@ -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); }