tracing: Fixes for v6.0-rc1
Steven Rostedt
maintainerLinus,
Various fixes for tracing:
- Suppress the errors that is_signed_type() causes static analysis tools
- Fix a return value of traceprobe_parse_event_name()
- Fix NULL pointer dereference from failed ftrace enabling
- Fix NULL pointer dereference when asking for registers from eprobes
- Make eprobes consistent with kprobes/uprobes, filters and histograms
Please pull the latest trace-v6.0-rc1 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v6.0-rc1
Tag SHA1: e29cad9f0ae9b811dfb20fe56a4ab80f7e858e3a Head SHA1: 2a64880ed7589361fec95f30065d433842c0d450
Bart Van Assche (1):
tracing: Suppress sparse warnings triggered by is_signed_type()
Lukas Bulwahn (1):
tracing: React to error return from traceprobe_parse_event_name()
Steven Rostedt (Google) (7):
tracing/perf: Fix double put of trace event when init fails tracing/eprobes: Do not allow eprobes to use $stack, or % for regs tracing/eprobes: Do not hardcode $comm as a string tracing/eprobes: Fix reading of string fields tracing/eprobes: Have event probes be consistent with kprobes and uprobes tracing/probes: Have kprobes and uprobes use $COMM too
tracing: Have filter accept "common_cpu" to be consistent
Yang Jihong (1):
ftrace: Fix NULL pointer dereference in is_ftrace_trampoline when ftrace is dead
----
include/linux/trace_events.h | 12 ++++++ kernel/trace/ftrace.c | 10 +++++ kernel/trace/trace_eprobe.c | 93 +++++++++++++++++++++++++++++++++++++---- kernel/trace/trace_event_perf.c | 7 ++-- kernel/trace/trace_events.c | 1 + kernel/trace/trace_probe.c | 29 ++++++++----- 6 files changed, 131 insertions(+), 21 deletions(-)
---------------------------
include/linux/trace_events.h +12 -0
@@ -814,7 +814,19 @@ extern int trace_add_event_call(struct trace_event_call *call);extern int trace_remove_event_call (struct trace_event_call *call);extern int trace_event_get_offsets (struct trace_event_call *call); +/* +* There is no known way to check signedness of __bitwise types without +* triggering a sparse warning. Hence the #ifdef __CHECKER__. +* +* Since there is another definition of is_signed_type() in <linux/overflow.h>, +* undefine is_signed_type() before redefining it. +*/ +#undef is_signed_type +#ifdef __CHECKER__ +#define is_signed_type (type) 0 +#else #define is_signed_type (type) (((type)(-1)) < (type)1) +#endif int ftrace_set_clr_event (struct trace_array *tr,char *buf,int set);int trace_set_clr_event (const char *system,const char *event,int set);
kernel/trace/ftrace.c +10 -0
@@ -2937,6 +2937,16 @@ int ftrace_startup(struct ftrace_ops *ops, int command)ftrace_startup_enable (command); +/* +* If ftrace is in an undefined state, we just remove ops from list +* to prevent the NULL pointer, instead of totally rolling it back and +* free trampoline, because those actions could cause further damage. +*/ +if (unlikely (ftrace_disabled)) { +__unregister_ftrace_function (ops); +return -ENODEV ; + } + ops->flags &= ~FTRACE_OPS_FL_ADDING ;return 0 ;
kernel/trace/trace_eprobe.c +86 -7
144 lines not on this page · raw message
kernel/trace/trace_event_perf.c +4 -3
@@ -157,7 +157,7 @@ static void perf_trace_event_unreg(struct perf_event *p_event)int i;if (--tp_event->perf_refcount >0 ) - goto out; +return ; tp_event->class->reg (tp_event,TRACE_REG_PERF_UNREGISTER ,NULL );
@@ -176,8 +176,6 @@ static void perf_trace_event_unreg(struct perf_event *p_event) perf_trace_buf[i] =NULL ; } } -out: -trace_event_put_ref (tp_event); }static int perf_trace_event_open (struct perf_event *p_event)
@@ -241,6 +239,7 @@ void perf_trace_destroy(struct perf_event *p_event)mutex_lock (&event_mutex);perf_trace_event_close (p_event);perf_trace_event_unreg (p_event); +trace_event_put_ref (p_event->tp_event);mutex_unlock (&event_mutex); }
@@ -292,6 +291,7 @@ void perf_kprobe_destroy(struct perf_event *p_event)mutex_lock (&event_mutex);perf_trace_event_close (p_event);perf_trace_event_unreg (p_event); +trace_event_put_ref (p_event->tp_event);mutex_unlock (&event_mutex);destroy_local_trace_kprobe (p_event->tp_event);
@@ -347,6 +347,7 @@ void perf_uprobe_destroy(struct perf_event *p_event)mutex_lock (&event_mutex);perf_trace_event_close (p_event);perf_trace_event_unreg (p_event); +trace_event_put_ref (p_event->tp_event);mutex_unlock (&event_mutex);destroy_local_trace_uprobe (p_event->tp_event); }
kernel/trace/trace_events.c +1 -0
@@ -176,6 +176,7 @@ static int trace_define_generic_fields(void)__generic_field (int,CPU ,FILTER_CPU );__generic_field (int, cpu,FILTER_CPU ); +__generic_field (int, common_cpu,FILTER_CPU ); __generic_field(char *, COMM, FILTER_COMM); __generic_field(char *, comm, FILTER_COMM);
kernel/trace/trace_probe.c +18 -11
@@ -283,7 +283,14 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,int ret =0 ;int len; -if (strcmp (arg,"retval" ) ==0 ) { +if (flags &TPARG_FL_TPOINT ) { +if (code->data) +return -EFAULT ; + code->data =kstrdup (arg,GFP_KERNEL ); +if (!code->data) +return -ENOMEM ; + code->op =FETCH_OP_TP_ARG ; + }else if (strcmp (arg,"retval" ) ==0 ) {if (flags &TPARG_FL_RETURN ) { code->op =FETCH_OP_RETVAL ; }else {
@@ -307,7 +314,7 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t, } }else goto inval_var; - }else if (strcmp (arg,"comm" ) ==0 ) { + }else if (strcmp (arg,"comm" ) ==0 ||strcmp (arg,"COMM" ) ==0 ) { code->op =FETCH_OP_COMM ; #ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API } else if (((flags & TPARG_FL_MASK) ==
@@ -323,13 +330,6 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t, code->op =FETCH_OP_ARG ; code->param = (unsigned int )param -1 ;#endif - }else if (flags &TPARG_FL_TPOINT ) { -if (code->data) -return -EFAULT ; - code->data =kstrdup (arg,GFP_KERNEL ); -if (!code->data) -return -ENOMEM ; - code->op =FETCH_OP_TP_ARG ; }else goto inval_var;
@@ -384,6 +384,11 @@ parse_probe_arg(char *arg, const struct fetch_type *type,break ;case '%' :/* named register */ +if (flags &TPARG_FL_TPOINT ) { +/* eprobes do not handle registers */ +trace_probe_log_err (offs,BAD_VAR ); +break ; + } ret =regs_query_register_offset (arg +1 );if (ret >=0 ) { code->op =FETCH_OP_REG ;
@@ -617,9 +622,11 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,/* * Since $comm and immediate string can not be dereferenced, -* we can find those by strcmp. +* we can find those by strcmp. But ignore for eprobes. */ -if (strcmp (arg,"$comm" ) ==0 ||strncmp (arg,"\\\"" ,2 ) ==0 ) { +if (!(flags &TPARG_FL_TPOINT ) && + (strcmp (arg,"$comm" ) ==0 ||strcmp (arg,"$COMM" ) ==0 || +strncmp (arg,"\\\"" ,2 ) ==0 )) {/* The type of $comm must be "string", and not an array. */ if (parg->count || (t &&strcmp (t,"string" ))) goto out;