perf report: Add validation of call-chain entries

Add boundary checks for call-chain events. In case of corrupted
entries we could crash otherwise.

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Ingo Molnar 2009-06-18 08:00:17 +02:00
parent b25bcf2f13
commit 7522060c95
2 changed files with 56 additions and 38 deletions

View file

@ -337,6 +337,16 @@ enum perf_event_type {
*/
};
#define MAX_STACK_DEPTH 255
struct perf_callchain_entry {
__u16 nr;
__u16 hv;
__u16 kernel;
__u16 user;
__u64 ip[MAX_STACK_DEPTH];
};
#ifdef __KERNEL__
/*
* Kernel-internal data types and definitions:
@ -652,16 +662,6 @@ extern void perf_counter_fork(struct task_struct *tsk);
extern void perf_counter_task_migration(struct task_struct *task, int cpu);
#define MAX_STACK_DEPTH 255
struct perf_callchain_entry {
u16 nr;
u16 hv;
u16 kernel;
u16 user;
u64 ip[MAX_STACK_DEPTH];
};
extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs);
extern int sysctl_perf_counter_paranoid;