Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-08-16 22:01:45 +0200
committerJiri Slaby <jslaby@suse.cz>2019-08-16 22:25:10 +0200
commit617db9dd7719b9fec11f33cb8eea3fa5d35996a9 (patch)
tree070f4fa76a90e2341ab8df14de1981c57ca0a809
parent1d051f575f2f0c4d120afbe3b8134f97dbd49424 (diff)
perf probe: Avoid calling freeing routine multiple times for
same pointer (bnc#1012628).
-rw-r--r--patches.kernel.org/5.2.9-100-perf-probe-Avoid-calling-freeing-routine-multip.patch53
-rw-r--r--series.conf1
2 files changed, 54 insertions, 0 deletions
diff --git a/patches.kernel.org/5.2.9-100-perf-probe-Avoid-calling-freeing-routine-multip.patch b/patches.kernel.org/5.2.9-100-perf-probe-Avoid-calling-freeing-routine-multip.patch
new file mode 100644
index 0000000000..d2dda59eb7
--- /dev/null
+++ b/patches.kernel.org/5.2.9-100-perf-probe-Avoid-calling-freeing-routine-multip.patch
@@ -0,0 +1,53 @@
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Thu, 18 Jul 2019 11:28:37 -0300
+Subject: [PATCH] perf probe: Avoid calling freeing routine multiple times for
+ same pointer
+References: bnc#1012628
+Patch-mainline: 5.2.9
+Git-commit: d95daf5accf4a72005daa13fbb1d1bd8709f2861
+
+[ Upstream commit d95daf5accf4a72005daa13fbb1d1bd8709f2861 ]
+
+When perf_add_probe_events() we call cleanup_perf_probe_events() for the
+pev pointer it receives, then, as part of handling this failure the main
+'perf probe' goes on and calls cleanup_params() and that will again call
+cleanup_perf_probe_events()for the same pointer, so just set nevents to
+zero when handling the failure of perf_add_probe_events() to avoid the
+double free.
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Masami Hiramatsu <mhiramat@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Link: https://lkml.kernel.org/n/tip-x8qgma4g813z96dvtw9w219q@git.kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ tools/perf/builtin-probe.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
+index 8bb124e55c6d..2c376f5b2120 100644
+--- a/tools/perf/builtin-probe.c
++++ b/tools/perf/builtin-probe.c
+@@ -698,6 +698,16 @@ __cmd_probe(int argc, const char **argv)
+
+ ret = perf_add_probe_events(params.events, params.nevents);
+ if (ret < 0) {
++
++ /*
++ * When perf_add_probe_events() fails it calls
++ * cleanup_perf_probe_events(pevs, npevs), i.e.
++ * cleanup_perf_probe_events(params.events, params.nevents), which
++ * will call clear_perf_probe_event(), so set nevents to zero
++ * to avoid cleanup_params() to call clear_perf_probe_event() again
++ * on the same pevs.
++ */
++ params.nevents = 0;
+ pr_err_with_code(" Error: Failed to add events.", ret);
+ return ret;
+ }
+--
+2.22.0
+
diff --git a/series.conf b/series.conf
index 7976f5b16c..4328077a50 100644
--- a/series.conf
+++ b/series.conf
@@ -1120,6 +1120,7 @@
patches.kernel.org/5.2.9-097-perf-tools-Fix-proper-buffer-size-for-feature-p.patch
patches.kernel.org/5.2.9-098-perf-stat-Fix-segfault-for-event-group-in-repea.patch
patches.kernel.org/5.2.9-099-perf-session-Fix-loading-of-compressed-data-spl.patch
+ patches.kernel.org/5.2.9-100-perf-probe-Avoid-calling-freeing-routine-multip.patch
########################################################
# Build fixes that apply to the vanilla kernel too.