summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-buildid-list.c
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2012-05-15 13:28:12 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-05-22 12:59:52 -0300
commit444d28663936e286c752f05feca44d6041b1fce4 (patch)
tree3c8cdf5a2bab4e57921dd36f99b0f36c7df04e53 /tools/perf/builtin-buildid-list.c
parent1a1ed1ba6778a5bc5702cebe276ab080a0b78115 (diff)
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>
Diffstat (limited to 'tools/perf/builtin-buildid-list.c')
0 files changed, 0 insertions, 0 deletions