From: Arnaldo Carvalho de Melo Date: Thu, 11 Mar 2010 18:53:11 +0000 (-0300) Subject: perf record: Don't try to find buildids in a zero sized file X-Git-Tag: v2.6.34-rc2~19^2~1 X-Git-Url: https://git.kernelconcepts.de/?a=commitdiff_plain;h=9f591fd76afdc0e5192e9ed00a36f8efc0b4dfe6;p=karo-tx-linux.git perf record: Don't try to find buildids in a zero sized file Fixing this symptom: [acme@mica linux-2.6-tip]$ perf record -a -f Fatal: Permission error - are you root? Bus error [acme@mica linux-2.6-tip]$ I.e. if for some reason no data is collected, in this case a non root user trying to do systemwide profiling, no data will be collected, and then we end up trying to mmap a zero sized file and access the file header, b00m. Reported-by: Ingo Molnar Signed-off-by: Arnaldo Carvalho de Melo Cc: Frédéric Weisbecker Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Paul Mackerras Cc: LKML-Reference: <1268333592-30872-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar --- diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index b09d3b27ca14..3b8b6387c47c 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -395,6 +395,9 @@ static int process_buildids(void) { u64 size = lseek(output, 0, SEEK_CUR); + if (size == 0) + return 0; + session->fd = output; return __perf_session__process_events(session, post_processing_offset, size - post_processing_offset,