linux/tools/perf
Jiri Olsa b9a46bba88 perf top: Fix events overflow in top command
The snprintf function returns number of printed characters even if it
cross the size parameter. So passing enough events via '-e' parameter
will cause segmentation fault.

It's reproduced by following command:

perf top -e `perf list | grep Tracepoint | awk -F'[' '\
{gsub(/[[:space:]]+/,"",$1);array[FNR]=$1}END{outputs=array[1];\
for (i=2;i<=FNR;i++){ outputs=outputs "," array[i];};print outputs}'`

Attached patch is adding SNPRINTF macro that provides the overflow check
and returns actuall number of printed characters.

Reported-by: Han Pingtian <phan@redhat.com>
Cc: Han Pingtian <phan@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1299528821-17521-2-git-send-email-jolsa@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2011-03-10 10:54:13 -03:00
..
arch [S390] perf: add DWARF register lookup for s390 2011-01-05 12:47:31 +01:00
bench perf tool: Fix gcc 4.6.0 issues 2011-02-07 12:41:41 -02:00
Documentation perf lock: Document valid sort keys 2011-02-23 07:29:33 -03:00
python perf evlist: Store pointer to the cpu and thread maps 2011-01-31 12:40:52 -02:00
scripts perf script: Finish the rename from trace to script 2010-12-25 11:29:02 -02:00
util perf top: Fix events overflow in top command 2011-03-10 10:54:13 -03:00
.gitignore perf tools: Makefile: Remove various and sundry cruft 2011-02-18 07:43:06 -02:00
builtin-annotate.c perf tools: Improve support for sessions with multiple events 2011-03-06 13:13:40 -03: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 Merge commit 'v2.6.37-rc8' into perf/core 2011-01-04 08:08:54 +01:00
builtin-diff.c perf tools: Kill event_t typedef, use 'union perf_event' instead 2011-01-29 16:25:37 -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: Kill event_t typedef, use 'union perf_event' instead 2011-01-29 16:25:37 -02:00
builtin-kmem.c perf tools: Kill event_t typedef, use 'union perf_event' instead 2011-01-29 16:25:37 -02:00
builtin-kvm.c perf options: Type check all the remaining OPT_ variants 2010-05-17 16:22:41 -03:00
builtin-list.c perf list: Allow filtering list of events 2011-02-17 15:38:58 -02:00
builtin-lock.c perf lock: Document valid sort keys 2011-02-23 07:29:33 -03:00
builtin-probe.c perf probe: Use %td for pointer arithmetic result 2011-01-31 19:45:38 -02:00
builtin-record.c perf: Set filters before mmaping events 2011-03-02 16:05:51 +01:00
builtin-report.c perf report tui: Improve multi event session support 2011-03-06 13:14:53 -03:00
builtin-sched.c perf tool: Fix gcc 4.6.0 issues 2011-02-07 12:41:41 -02:00
builtin-script.c perf tools: Kill event_t typedef, use 'union perf_event' instead 2011-01-29 16:25:37 -02:00
builtin-stat.c perf tool: Add cgroup support 2011-02-16 13:30:48 +01:00
builtin-test.c perf evlist: Store pointer to the cpu and thread maps 2011-01-31 12:40:52 -02:00
builtin-timechart.c Merge branch 'perf/urgent' into perf/core 2011-03-04 10:40:25 +01:00
builtin-top.c perf top tui: Wait till the first sample to refresh the screen. 2011-03-01 10:43:03 -03:00
builtin.h perf: Rename 'perf trace' to 'perf script' 2010-11-16 19:37:44 +01:00
command-list.txt Merge branch 'perf/rename' into perf/core 2010-12-01 09:22:19 +01: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
feature-tests.mak perf tools: Remove hardcoded include paths for elfutils 2010-11-19 16:38:04 -02:00
Makefile perf tools: Makefile: Remove various and sundry cruft 2011-02-18 07:43:06 -02:00
MANIFEST perf packaging: add memcpy to perf MANIFEST 2010-11-30 23:00:10 -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 evsel: Fix order of event list deletion 2011-01-11 12:51:03 -02:00
perf.h perf record: Move perf_mmap__write_tail to perf.h 2011-01-22 19:56:29 -02:00