diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2011-05-21 11:07:24 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2011-05-21 21:12:13 -0400 |
commit | eac9eacee1602710dda47c517ad0b61ac6f429bf (patch) | |
tree | ea59e724cec133e301cd73306e31362a1ddfe8f3 /tools | |
parent | c5fc472171ec4f96d06d1ac039d88f9b89bb95db (diff) |
perf tools: Check we are able to read the event size on mmap
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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/session.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index fff66741f18d..61746b5866d8 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -1007,6 +1007,13 @@ remap: | |||
1007 | file_pos = file_offset + head; | 1007 | file_pos = file_offset + head; |
1008 | 1008 | ||
1009 | more: | 1009 | more: |
1010 | /* | ||
1011 | * Ensure we have enough space remaining to read | ||
1012 | * the size of the event in the headers. | ||
1013 | */ | ||
1014 | if (head + sizeof(event->header) > mmap_size) | ||
1015 | goto remap; | ||
1016 | |||
1010 | event = (union perf_event *)(buf + head); | 1017 | event = (union perf_event *)(buf + head); |
1011 | 1018 | ||
1012 | if (session->header.needs_swap) | 1019 | if (session->header.needs_swap) |