tracing: A few minor fix ups
Steven Rostedt
maintainerLinus,
A few more tracing fixes:
- Fixed a buffer overflow by checking nr_args correctly in probes
- Fixed a warning that is reported by clang
- Fixed a possible memory leak in error path of filter processing
- Fixed the selftest that checks for failures, but wasn't failing
- Minor clean up on call site output of a memory trace event
Please pull the latest trace-v5.4-3 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v5.4-3
Tag SHA1: 6bd391b341525bebf22f3fbbaea7ffb35f7cccb6 Head SHA1: 8ed4889eb83179dbc9a105cfed65cc42ecb61097
Changbin Du (1):
mm, tracing: Print symbol name for call_site in trace events
Masami Hiramatsu (1):
tracing/probe: Fix to check the difference of nr_args before adding probe
Nathan Chancellor (1):
tracing: Fix clang -Wint-in-bool-context warnings in IF_ASSIGN macro
Navid Emamdoost (1):
tracing: Have error path in predicate_parse() free its allocated memory
Steven Rostedt (VMware) (1):
selftests/ftrace: Fix same probe error test
----
include/trace/events/kmem.h | 7 ++++--- kernel/trace/trace.h | 10 +++++----- kernel/trace/trace_events_filter.c | 6 ++++-- kernel/trace/trace_probe.c | 16 ++++++++++++++++ .../ftrace/test.d/kprobe/kprobe_syntax_errors.tc | 2 +- 5 files changed, 30 insertions(+), 11 deletions(-)
---------------------------
include/trace/events/kmem.h +4 -3
@@ -35,8 +35,8 @@ DECLARE_EVENT_CLASS(kmem_alloc, __entry->gfp_flags = gfp_flags; ), - TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s", - __entry->call_site, + TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s", + (void *)__entry->call_site, __entry->ptr, __entry->bytes_req, __entry->bytes_alloc,
@@ -131,7 +131,8 @@ DECLARE_EVENT_CLASS(kmem_free, __entry->ptr = ptr; ), -TP_printk ("call_site=%lx ptr=%p" , __entry->call_site, __entry->ptr) +TP_printk ("call_site=%pS ptr=%p" , + (void *)__entry->call_site, __entry->ptr) ); DEFINE_EVENT(kmem_free, kfree,
kernel/trace/trace.h +5 -5
@@ -365,11 +365,11 @@ static inline struct trace_array *top_trace_array(void) __builtin_types_compatible_p(typeof(var), type *) #undef IF_ASSIGN -#define IF_ASSIGN(var, entry, etype, id) \ -if (FTRACE_CMP_TYPE (var, etype)) { \ - var = (typeof (var))(entry); \ -WARN_ON (id && (entry)->type != id); \ -break ; \ +#define IF_ASSIGN(var, entry, etype, id) \ +if (FTRACE_CMP_TYPE (var, etype)) { \ + var = (typeof (var))(entry); \ +WARN_ON (id !=0 && (entry)->type != id); \ +break ; \ }/* Will cause compile errors if type is not found. */
kernel/trace/trace_events_filter.c +4 -2
@@ -452,8 +452,10 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,switch (*next) {case '(' :/* #2 */ -if (top - op_stack > nr_parens) -return ERR_PTR (-EINVAL ); +if (top - op_stack > nr_parens) { + ret = -EINVAL ; + goto out_free; + } *(++top) = invert;continue ;case '!' :/* #3 */
kernel/trace/trace_probe.c +16 -0
@@ -178,6 +178,16 @@ void __trace_probe_log_err(int offset, int err_type)if (!command)return ; +if (trace_probe_log.index >= trace_probe_log.argc) { +/** +* Set the error position is next to the last arg + space. +* Note that len includes the terminal null and the cursor +* appaers at pos + 1. +*/ + pos = len; + offset =0 ; + } +/* And make a command string from argv array */ p = command;for (i =0 ; i < trace_probe_log.argc; i++) {
@@ -1084,6 +1094,12 @@ int trace_probe_compare_arg_type(struct trace_probe *a, struct trace_probe *b) {int i; +/* In case of more arguments */ +if (a->nr_args < b->nr_args) +return a->nr_args +1 ; +if (a->nr_args > b->nr_args) +return b->nr_args +1 ; +for (i =0 ; i < a->nr_args; i++) { if ((b->nr_args <= i) || ((a->args[i].type != b->args[i].type) ||
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc +1 -1
@@ -95,7 +95,7 @@ echo 'p:kprobes/testevent _do_fork abcd=\1' > kprobe_events check_error 'p:kprobes/testevent _do_fork ^bcd=\1' # DIFF_ARG_TYPE check_error 'p:kprobes/testevent _do_fork ^abcd=\1:u8' # DIFF_ARG_TYPE check_error 'p:kprobes/testevent _do_fork ^abcd=\"foo"' # DIFF_ARG_TYPE -check_error '^p:kprobes/testevent _do_fork' # SAME_PROBE +check_error '^p:kprobes/testevent _do_fork abcd=\1' # SAME_PROBE fi exit 0
The pull request you sent on Sun, 29 Sep 2019 16:17:15 -0400:
The pull request you sent on Sun, 29 Sep 2019 16:17:15 -0400:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.gittrace-v5.4-3
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/cf4f493b102399adea3cf65cdde7161c17fb605c
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker