Skip to content

Commit

Permalink
perf tools: Check we are able to read the event size on mmap
Browse files Browse the repository at this point in the history
Check we have enough mmaped space to read the current event
size from its headers, otherwise we may dereference some
hell there.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
  • Loading branch information
fweisbec committed May 22, 2011
1 parent c5fc472 commit eac9eac
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,13 @@ int __perf_session__process_events(struct perf_session *session,
file_pos = file_offset + head;

more:
/*
* Ensure we have enough space remaining to read
* the size of the event in the headers.
*/
if (head + sizeof(event->header) > mmap_size)
goto remap;

event = (union perf_event *)(buf + head);

if (session->header.needs_swap)
Expand Down

0 comments on commit eac9eac

Please sign in to comment.