linux-stable/tools/perf
Stephane Eranian 444d286639 perf tools: Fix piped mode read code
In __perf_session__process_pipe_events(), there was a risk we would read
more than what a union perf_event struct can hold. this could happen in
case, perf is reading a file which contains new record types it does not
know about and which are larger than anything it knows about.

In general, perf is supposed to skip records it does not understand, but
in pipe mode, those have to be read and ignored.  The fixed size header
contains the size of the record, but that size may be larger than union
perf_event, yet it was used as the backing to the read in:

  union perf_event event;
  void *p;

  size = event->header.size;

  p = &event;
  p += sizeof(struct perf_event_header);
  if (size - sizeof(struct perf_event_header)) {
    err = readn(self->fd, p, size - sizeof(struct perf_event_header));

We fix this by allocating a buffer based on the size reported in the
header. We reuse the buffer as much as we can. We realloc in case it
becomes too small. In the  common case, the performance impact is
negligible.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1337081295-10303-3-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-05-22 12:59:52 -03:00
..
arch perf tools: Use scnprintf where applicable 2012-03-14 12:36:19 -03:00
bench perf tool: Fix perf stack to non executable on x86_64 2012-02-06 19:14:17 -02:00
config perf report: Add a simple GTK2-based 'perf report' browser 2012-03-19 15:13:29 -03:00
Documentation perf record: Fix documentation for branch stack sampling 2012-05-22 12:47:45 -03:00
python perf python: Use attr.watermark in twatch.py 2012-01-30 18:38:23 -02:00
scripts perf script: Add drop monitor script 2011-09-29 16:41:37 -03:00
ui perf annotate browser: Add key bindings help window 2012-05-12 16:36:55 -03:00
util perf tools: Fix piped mode read code 2012-05-22 12:59:52 -03:00
.gitignore perf tools: Ignore auto-generated bison/flex files 2012-04-14 13:50:39 -03:00
builtin-annotate.c perf annotate: Get rid of field_sep check 2012-01-08 13:29:34 -02:00
builtin-bench.c perf bench: Also allow measuring memset() 2012-01-24 20:25:32 -02:00
builtin-buildid-cache.c perf buildid: add perfconfig option to specify buildid cache dir 2010-06-05 09:34:04 -03:00
builtin-buildid-list.c perf report: Accept fifos as input file 2011-12-23 17:01:03 -02:00
builtin-diff.c perf diff: Fix to work with new hists design 2012-03-22 15:12:09 -03:00
builtin-evlist.c perf report: Accept fifos as input file 2011-12-23 17:01:03 -02:00
builtin-help.c perf options: Type check all the remaining OPT_ variants 2010-05-17 16:22:41 -03:00
builtin-inject.c perf inject: Fix broken perf inject -b 2012-05-22 12:59:28 -03:00
builtin-kmem.c perf: Have perf use the new libtraceevent.a library 2012-04-25 13:28:48 +02:00
builtin-kvm.c perf kvm: Do guest-only counting by default 2012-01-06 15:47:37 -02:00
builtin-list.c perf list: Allow filtering list of events 2011-02-17 15:38:58 -02:00
builtin-lock.c perf: Have perf use the new libtraceevent.a library 2012-04-25 13:28:48 +02:00
builtin-probe.c perf probe: Rename target_module to target 2012-02-02 17:39:15 -02:00
builtin-record.c perf tools: rename HEADER_TRACE_INFO to HEADER_TRACING_DATA 2012-05-22 12:57:46 -03:00
builtin-report.c Merge remote-tracking branch 'tip/perf/urgent' into perf/core 2012-05-18 13:13:33 -03:00
builtin-sched.c perf: Have perf use the new libtraceevent.a library 2012-04-25 13:28:48 +02:00
builtin-script.c perf: Have perf use the new libtraceevent.a library 2012-04-25 13:28:48 +02:00
builtin-stat.c Merge remote-tracking branch 'tip/perf/urgent' into perf/core 2012-05-18 13:13:33 -03:00
builtin-test.c perf test: Move parse event automated tests to separated object 2012-05-22 11:19:16 -03:00
builtin-timechart.c perf report: Accept fifos as input file 2011-12-23 17:01:03 -02:00
builtin-top.c perf target: Add cpu flag to sample_type if target has cpu 2012-05-22 12:37:12 -03:00
builtin.h perf tools: Make perf.data more self-descriptive (v8) 2011-10-07 17:01:24 -03:00
command-list.txt perf evlist: New command to list the names of events present in a perf.data file 2011-03-15 11:10:48 -03:00
CREDITS
design.txt perf: Fix few typos + cosmetics 2010-01-13 17:39:44 +01:00
Makefile perf tools: Always try to build libtraceevent 2012-05-22 12:35:29 -03:00
MANIFEST perf tools: Fix out of tree compiles 2012-02-13 22:46:41 -02:00
perf-archive.sh perf archive: Correct cutting of symbolic link 2012-04-14 13:52:15 -03:00
perf.c perf tools: Simplify debugfs mountpoint handling code 2011-11-28 10:11:28 -02:00
perf.h perf target: Split out perf_target handling code 2012-05-02 15:41:11 -03:00