All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf tools: check perf_event_paranoid and kptr_restrict on 'perf top'
@ 2021-02-23  6:24 Jackie Liu
  2021-02-23 14:38 ` Jiri Olsa
  0 siblings, 1 reply; 2+ messages in thread
From: Jackie Liu @ 2021-02-23  6:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jackie Liu, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim

Perf top will segfault, we should give prompt information like perf
record instead of crashing directly.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 tools/perf/builtin-top.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 3673c04d16b6..b257fadba3bd 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1239,6 +1239,14 @@ static int __cmd_top(struct perf_top *top)
 			return ret;
 	}
 
+	if (symbol_conf.kptr_restrict && !evlist__exclude_kernel(top->evlist)) {
+		pr_warning(
+"Kernel address maps (/proc/{kallsyms,modules}) are restricted.\n\n"
+"Check /proc/sys/kernel/kptr_restrict and /proc/sys/kernel/perf_event_paranoid.\n\n"
+"Kernel samples will not be resolved.\n");
+		return -1;
+	}
+
 	ret = callchain_param__setup_sample_type(&callchain_param);
 	if (ret)
 		return ret;
-- 
2.25.1


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

end of thread, other threads:[~2021-02-23 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-23  6:24 [PATCH] perf tools: check perf_event_paranoid and kptr_restrict on 'perf top' Jackie Liu
2021-02-23 14:38 ` Jiri Olsa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.