linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf evsel: Fix to perf-stat malloc corruption on arm64 platforms
@ 2017-04-26  9:26 Ganapatrao Kulkarni
  2017-04-26 14:50 ` Mark Rutland
  0 siblings, 1 reply; 8+ messages in thread
From: Ganapatrao Kulkarni @ 2017-04-26  9:26 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Will.Deacon, catalin.marinas, mark.rutland, acme,
	alexander.shishkin, peterz, mingo, jnair, gpkulkarni

In some cases, ncpus used for perf_evsel__alloc_fd and for
perf_evsel__close are not the same, this is causing memory
overwrite/corruption.

Fixing issue by using same ncpus in perf_evsel__alloc_fd.

This bug is more evident on arm64 platforms, which uses
cpu_map(cpus) for PMU core devices.

Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
---
 tools/perf/util/evsel.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ac59710..0dc94d7 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1489,7 +1489,9 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
 		nthreads = threads->nr;
 
 	if (evsel->fd == NULL &&
-	    perf_evsel__alloc_fd(evsel, cpus->nr, nthreads) < 0)
+	    perf_evsel__alloc_fd(evsel,
+				evsel->cpus ? evsel->cpus->nr : cpus->nr,
+				nthreads) < 0)
 		return -ENOMEM;
 
 	if (evsel->cgrp) {
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-04-27 17:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26  9:26 [PATCH] perf evsel: Fix to perf-stat malloc corruption on arm64 platforms Ganapatrao Kulkarni
2017-04-26 14:50 ` Mark Rutland
2017-04-26 17:12   ` Mark Rutland
2017-04-26 18:19     ` Ganapatrao Kulkarni
2017-04-27 14:34       ` Mark Rutland
2017-04-27 15:46         ` Ganapatrao Kulkarni
2017-04-27 15:52           ` Mark Rutland
2017-04-27 17:24             ` Ganapatrao Kulkarni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).