perf record: Don't try to find buildids in a zero sized file
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 11 Mar 2010 18:53:11 +0000 (15:53 -0300)
committerIngo Molnar <mingo@elte.hu>
Thu, 11 Mar 2010 19:00:32 +0000 (20:00 +0100)
commit9f591fd76afdc0e5192e9ed00a36f8efc0b4dfe6
tree6692dc95d4d799431a8b403a206660546f066a16
parent639fe4b12f92b54c9c3b38c82cdafaa38cfd3e63
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 <mingo@elte.hu>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: <stable@kernel.org>
LKML-Reference: <1268333592-30872-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-record.c