Messages in this thread Patch in this message | | | From | Jiri Olsa <> | Subject | [PATCH 06/10] libperf: Do not allow PERF_FORMAT_GROUP in perf_evsel__read | Date | Tue, 22 Jun 2021 17:39:14 +0200 |
| |
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
| |