[PATCH 2/3] Revert "perf session: Avoid infinite loop when seeing invalid header.size"

Petr Malat
2020-11-24T10:00:29Z

An event may be split by a buffer boundary, we should not abort processing
if that happens.

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 | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 593d5a823eba..e57b0d09d196 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <errno.h>
#include <inttypes.h>
-#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/zalloc.h>
#include <api/fs/fs.h>
@@ -2045,9 +2044,7 @@ fetch_mmaped_event(struct perf_session *session,
/* We're not fetching the event so swap back again */
if (session->header.needs_swap)
perf_event_header__bswap(&event->header);
- pr_debug("%s: head=%#" PRIx64 " event->header_size=%#x, mmap_size=%#zx: fuzzed perf.data?\n",
- __func__, head, event->header.size, mmap_size);
- return ERR_PTR(-EINVAL);
+ return NULL;
}

return event;
@@ -2065,9 +2062,6 @@ static int __perf_session__process_decomp_events(struct perf_session *session)
while (decomp->head < decomp->size && !session_done()) {
union perf_event *event = fetch_mmaped_event(session, decomp->head, decomp->size, decomp->data);

- if (IS_ERR(event))
- return PTR_ERR(event);
-
if (!event)
break;

@@ -2167,9 +2161,6 @@ reader__process_events(struct reader *rd, struct perf_session *session,

more:
event = fetch_mmaped_event(session, head, mmap_size, buf);
- if (IS_ERR(event))
- return PTR_ERR(event);
-
if (!event) {
if (mmaps[map_idx]) {
munmap(mmaps[map_idx], mmap_size);
--
2.20.1