[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210428111150.1343388-2-sashal@kernel.org>
Date: Wed, 28 Apr 2021 07:11:50 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Thomas Richter <tmricht@...ux.ibm.com>,
Alexander Schmidt <alexschm@...ibm.com>,
Namhyung Kim <namhyung@...nel.org>,
Heiko Carstens <hca@...ux.ibm.com>,
Sumanth Korikkar <sumanthk@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH AUTOSEL 5.4 2/2] perf ftrace: Fix access to pid in array when setting a pid filter
From: Thomas Richter <tmricht@...ux.ibm.com>
[ Upstream commit 671b60cb6a897a5b3832fe57657152f2c3995e25 ]
Command 'perf ftrace -v -- ls' fails in s390 (at least 5.12.0rc6).
The root cause is a missing pointer dereference which causes an
array element address to be used as PID.
Fix this by extracting the PID.
Output before:
# ./perf ftrace -v -- ls
function_graph tracer is used
write '-263732416' to tracing/set_ftrace_pid failed: Invalid argument
failed to set ftrace pid
#
Output after:
./perf ftrace -v -- ls
function_graph tracer is used
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
4) | rcu_read_lock_sched_held() {
4) 0.552 us | rcu_lockdep_current_cpu_online();
4) 6.124 us | }
Reported-by: Alexander Schmidt <alexschm@...ibm.com>
Signed-off-by: Thomas Richter <tmricht@...ux.ibm.com>
Acked-by: Namhyung Kim <namhyung@...nel.org>
Cc: Heiko Carstens <hca@...ux.ibm.com>
Cc: Sumanth Korikkar <sumanthk@...ux.ibm.com>
Cc: Sven Schnelle <svens@...ux.ibm.com>
Cc: Vasily Gorbik <gor@...ux.ibm.com>
Link: http://lore.kernel.org/lkml/20210421120400.2126433-1-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
tools/perf/builtin-ftrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index d5adc417a4ca..40b179f54428 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -161,7 +161,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
scnprintf(buf, sizeof(buf), "%d",
- ftrace->evlist->core.threads->map[i]);
+ perf_thread_map__pid(ftrace->evlist->core.threads, i));
if (append_tracing_file("set_ftrace_pid", buf) < 0)
return -1;
}
--
2.30.2
Powered by blists - more mailing lists