linux/tools/perf
Stephane Eranian 8aa8a7c80c perf record: Fix buffer overrun bug in tracepoint_id_to_path()
This patch fixes a buffer overrun bug in
tracepoint_id_to_path(). The bug manisfested itself as a memory
error reported by perf record. I ran into it with perf sched:

 $ perf sched rec noploop 2 noploop for 2 seconds
 [ perf record: Woken up 14 times to write data ]
 [ perf record: Captured and wrote 42.701 MB perf.data (~1865622 samples) ]
 Fatal: No memory to alloc tracepoints list

It turned out that tracepoint_id_to_path() was reading the
tracepoint id using read() but the buffer was not large enough
to include the \n terminator for id with 4 digits or more.

The patch fixes the problem by extending the buffer to a more
reasonable size covering all possible id length include \n
terminator. Note that atoll() stops at the first non digit
character, thus it is not necessary to clear the buffer between
each read.

Signed-off-by: Stephane Eranian <eranian@google.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: fweisbec@gmail.com
Cc: dsahern@gmail.com
Link: http://lkml.kernel.org/r/20120313155102.GA6465@quad
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-13 17:01:28 +01:00
..
arch perf/powerpc: Fix build for PowerPC with uclibc toolchains 2011-11-25 14:11:27 +11:00
bench perf tools: Fix perf stack to non executable on x86_64 2012-02-06 18:54:06 -02:00
config perf tools: git mv tools/perf/{features-tests.mak,config/} 2011-04-19 08:18:36 -03:00
Documentation Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-01-15 11:26:35 -08:00
python perf evlist: Store pointer to the cpu and thread maps 2011-01-31 12:40:52 -02:00
scripts perf script: Add drop monitor script 2011-09-29 16:41:37 -03:00
util perf record: Fix buffer overrun bug in tracepoint_id_to_path() 2012-03-13 17:01:28 +01:00
.gitignore perf tools: Makefile: Remove various and sundry cruft 2011-02-18 07:43:06 -02:00
builtin-annotate.c perf annotate: Get rid of field_sep check 2012-01-08 13:29:34 -02:00
builtin-bench.c perf options: Type check all the remaining OPT_ variants 2010-05-17 16:22:41 -03: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 tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02: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 tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02:00
builtin-kmem.c perf kmem: Fix a memory leak 2012-01-08 13:27:54 -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 report: Accept fifos as input file 2011-12-23 17:01:03 -02:00
builtin-probe.c perf tools: Fix broken build by defining _GNU_SOURCE in Makefile 2012-01-30 22:19:54 -02:00
builtin-record.c perf tools: Handle kernels that don't support attr.exclude_{guest,host} 2012-03-03 12:19:56 -03:00
builtin-report.c perf report: Accept fifos as input file 2011-12-23 17:01:03 -02:00
builtin-sched.c perf report: Accept fifos as input file 2011-12-23 17:01:03 -02:00
builtin-script.c perf script: Add missing closedir() calls 2012-01-08 12:35:41 -02:00
builtin-stat.c perf stat: Introduce get_ratio_color() helper 2012-01-03 14:36:32 -02:00
builtin-test.c perf test: Change type of '-v' option to INCR 2012-01-08 13:25:00 -02:00
builtin-timechart.c perf report: Accept fifos as input file 2011-12-23 17:01:03 -02:00
builtin-top.c perf tools: Handle kernels that don't support attr.exclude_{guest,host} 2012-03-03 12:19:56 -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 perf_counter tools: Add CREDITS file for Git contributors 2009-06-24 19:54:29 +02:00
design.txt perf: Fix few typos + cosmetics 2010-01-13 17:39:44 +01:00
Makefile perf tools: Fix broken build by defining _GNU_SOURCE in Makefile 2012-01-30 22:19:54 -02:00
MANIFEST perf tools: Add const.h to MANIFEST to make perf-tar-src-pkg work again 2012-01-06 15:52:18 -02:00
perf-archive.sh perf buildid: add perfconfig option to specify buildid cache dir 2010-06-05 09:34:04 -03:00
perf.c perf tools: Simplify debugfs mountpoint handling code 2011-11-28 10:11:28 -02:00
perf.h perf tools: Handle kernels that don't support attr.exclude_{guest,host} 2012-03-03 12:19:56 -03:00