mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
ftrace, perf: Avoid infinite event generation loop
Vince's perf-trinity fuzzer found yet another 'interesting' problem. When we sample the irq_work_exit tracepoint with period==1 (or PERF_SAMPLE_PERIOD) and we add an fasync SIGNAL handler we create an infinite event generation loop: ,-> <IPI> | irq_work_exit() -> | trace_irq_work_exit() -> | ... | __perf_event_overflow() -> (due to fasync) | irq_work_queue() -> (irq_work_list must be empty) '--------- arch_irq_work_raise() Similar things can happen due to regular poll() wakeups if we exceed the ring-buffer wakeup watermark, or have an event_limit. To avoid this, dis-allow sampling this particular tracepoint. In order to achieve this, create a special perf_perm function pointer for each event and call this (when set) on trying to create a tracepoint perf event. [ roasted: use expr... to allow for ',' in your expression ] Reported-by: Vince Weaver <vincent.weaver@maine.edu> Tested-by: Vince Weaver <vincent.weaver@maine.edu> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Dave Jones <davej@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Link: http://lkml.kernel.org/r/20131114152304.GC5364@laptop.programming.kicks-ass.net Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
801a76050b
commit
d5b5f391d4
5 changed files with 44 additions and 0 deletions
|
@ -248,6 +248,9 @@ struct ftrace_event_call {
|
|||
#ifdef CONFIG_PERF_EVENTS
|
||||
int perf_refcount;
|
||||
struct hlist_head __percpu *perf_events;
|
||||
|
||||
int (*perf_perm)(struct ftrace_event_call *,
|
||||
struct perf_event *);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -317,6 +320,19 @@ struct ftrace_event_file {
|
|||
} \
|
||||
early_initcall(trace_init_flags_##name);
|
||||
|
||||
#define __TRACE_EVENT_PERF_PERM(name, expr...) \
|
||||
static int perf_perm_##name(struct ftrace_event_call *tp_event, \
|
||||
struct perf_event *p_event) \
|
||||
{ \
|
||||
return ({ expr; }); \
|
||||
} \
|
||||
static int __init trace_init_perf_perm_##name(void) \
|
||||
{ \
|
||||
event_##name.perf_perm = &perf_perm_##name; \
|
||||
return 0; \
|
||||
} \
|
||||
early_initcall(trace_init_perf_perm_##name);
|
||||
|
||||
#define PERF_MAX_TRACE_SIZE 2048
|
||||
|
||||
#define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue