tracing: Fixes for v6.0-rc1
Steven Rostedt
maintainerLinus,
Various fixes for tracing:
- 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-2 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v6.0-rc1-2
Tag SHA1: 82fae5b2d7b77fb04c57f5b5344eddc490d2b0ff Head SHA1: b2380577d4fe1c0ef3fa50417f1e441c016e4cbe
Changes since v1: https://lore.kernel.org/all/[email protected]/
- Removed sparse warning "fix".
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
----
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 ++++++++----- 5 files changed, 119 insertions(+), 21 deletions(-)
---------------------------
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,a /* * 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;
The pull request you sent on Sun, 21 Aug 2022 16:16:14 -0400:
The pull request you sent on Sun, 21 Aug 2022 16:16:14 -0400:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.gittrace-v6.0-rc1-2
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/7fb312d2256da63e6e4c6e92d279a90fe44bcabd
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html