lkml.org 
[lkml]   [2021]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 06/10] libperf: Do not allow PERF_FORMAT_GROUP in perf_evsel__read
Date
The struct perf_counts_values can hold only first three
read_format bits. We can't allow PERF_FORMAT_GROUP,
otherwise we get segfault.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/lib/perf/evsel.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c
index bd8c2f19ef74..04e8386b3ed4 100644
--- a/tools/lib/perf/evsel.c
+++ b/tools/lib/perf/evsel.c
@@ -260,8 +260,12 @@ int perf_evsel__read_size(struct perf_evsel *evsel)
int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,
struct perf_counts_values *count)
{
+ u64 read_format = evsel->attr.read_format;
size_t size = perf_evsel__read_size(evsel);

+ if (read_format & PERF_FORMAT_GROUP)
+ return -EINVAL;
+
memset(count, 0, sizeof(*count));

if (FD(evsel, cpu, thread) < 0)
--
2.31.1
\
 
 \ /
  Last update: 2021-06-22 17:40    [W:0.848 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site