lkml.org 
[lkml]   [2020]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] perf session: Avoid infinite loop if an event is truncated
Date
If an event was truncated at the end of a perf.data file larger than
MAP_SIZE, the event reading code ended up in an infinite loop. Break
this loop by making sure the mapping window is always shifting
towards the end of the file.

Fixes: bb1835a3b86c ("perf session: Fix decompression of PERF_RECORD_COMPRESSED records")
Fixes: 57fc032ad643 ("perf session: Avoid infinite loop when seeing invalid header.size")
Signed-off-by: Petr Malat <oss@malat.biz>
---
tools/perf/util/session.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index e57b0d09d196..b73b85d99628 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -2168,6 +2168,12 @@ reader__process_events(struct reader *rd, struct perf_session *session,
}

page_offset = page_size * (head / page_size);
+ if (!page_offset) {
+ pr_err("%#" PRIx64 " [%#x]: truncated event\n",
+ file_offset + head);
+ err = -EINVAL;
+ goto out;
+ }
file_offset += page_offset;
head -= page_offset;
goto remap;
--
2.20.1
\
 
 \ /
  Last update: 2020-11-24 11:10    [W:0.110 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site