]> git.baikalelectronics.ru Git - kernel.git/commit
perf session: Remap buf if there is no space for event
authorDenis Nikitin <denik@chromium.org>
Wed, 30 Mar 2022 03:11:30 +0000 (20:11 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 9 Apr 2022 17:20:59 +0000 (14:20 -0300)
commita7ebe2af3e4bbf1f56f8d6cde228399fffd365d6
tree8f572aefe11eeaead1e074a25437b0f8c37c37c9
parentd4271083242fd264d98aa6773669d8f3f83d40a2
perf session: Remap buf if there is no space for event

If a perf event doesn't fit into remaining buffer space return NULL to
remap buf and fetch the event again.

Keep the logic to error out on inadequate input from fuzzing.

This fixes perf failing on ChromeOS (with 32b userspace):

  $ perf report -v -i perf.data
  ...
  prefetch_event: head=0x1fffff8 event->header_size=0x30, mmap_size=0x2000000: fuzzed or compressed perf.data?
  Error:
  failed to process sample

Fixes: b2b8c12aaad6fd23 ("perf session: Avoid infinite loop when seeing invalid header.size")
Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Denis Nikitin <denik@chromium.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220330031130.2152327-1-denik@chromium.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/session.c