From: Frederic Weisbecker Date: Sat, 21 May 2011 15:07:24 +0000 (+0200) Subject: perf tools: Check we are able to read the event size on mmap X-Git-Tag: v3.0-rc1~25^2~21^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eac9eacee1602710dda47c517ad0b61ac6f429bf;p=platform%2Fkernel%2Flinux-3.10.git 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 Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo Cc: Stephane Eranian --- diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index fff6674..61746b5 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1007,6 +1007,13 @@ remap: 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)