Commit cf4f493b authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'trace-v5.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt:
 "A few more tracing fixes:

   - Fix a buffer overflow by checking nr_args correctly in probes

   - Fix a warning that is reported by clang

   - Fix a possible memory leak in error path of filter processing

   - Fix the selftest that checks for failures, but wasn't failing

   - Minor clean up on call site output of a memory trace event"

* tag 'trace-v5.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  selftests/ftrace: Fix same probe error test
  mm, tracing: Print symbol name for call_site in trace events
  tracing: Have error path in predicate_parse() free its allocated memory
  tracing: Fix clang -Wint-in-bool-context warnings in IF_ASSIGN macro
  tracing/probe: Fix to check the difference of nr_args before adding probe
parents c710364f 8ed4889e
...@@ -35,8 +35,8 @@ DECLARE_EVENT_CLASS(kmem_alloc, ...@@ -35,8 +35,8 @@ DECLARE_EVENT_CLASS(kmem_alloc,
__entry->gfp_flags = gfp_flags; __entry->gfp_flags = gfp_flags;
), ),
TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s", TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
__entry->call_site, (void *)__entry->call_site,
__entry->ptr, __entry->ptr,
__entry->bytes_req, __entry->bytes_req,
__entry->bytes_alloc, __entry->bytes_alloc,
...@@ -131,7 +131,8 @@ DECLARE_EVENT_CLASS(kmem_free, ...@@ -131,7 +131,8 @@ DECLARE_EVENT_CLASS(kmem_free,
__entry->ptr = ptr; __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, DEFINE_EVENT(kmem_free, kfree,
......
...@@ -368,7 +368,7 @@ static inline struct trace_array *top_trace_array(void) ...@@ -368,7 +368,7 @@ static inline struct trace_array *top_trace_array(void)
#define IF_ASSIGN(var, entry, etype, id) \ #define IF_ASSIGN(var, entry, etype, id) \
if (FTRACE_CMP_TYPE(var, etype)) { \ if (FTRACE_CMP_TYPE(var, etype)) { \
var = (typeof(var))(entry); \ var = (typeof(var))(entry); \
WARN_ON(id && (entry)->type != id); \ WARN_ON(id != 0 && (entry)->type != id); \
break; \ break; \
} }
......
...@@ -452,8 +452,10 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, ...@@ -452,8 +452,10 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
switch (*next) { switch (*next) {
case '(': /* #2 */ case '(': /* #2 */
if (top - op_stack > nr_parens) if (top - op_stack > nr_parens) {
return ERR_PTR(-EINVAL); ret = -EINVAL;
goto out_free;
}
*(++top) = invert; *(++top) = invert;
continue; continue;
case '!': /* #3 */ case '!': /* #3 */
......
...@@ -178,6 +178,16 @@ void __trace_probe_log_err(int offset, int err_type) ...@@ -178,6 +178,16 @@ void __trace_probe_log_err(int offset, int err_type)
if (!command) if (!command)
return; 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 */ /* And make a command string from argv array */
p = command; p = command;
for (i = 0; i < trace_probe_log.argc; i++) { 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) ...@@ -1084,6 +1094,12 @@ int trace_probe_compare_arg_type(struct trace_probe *a, struct trace_probe *b)
{ {
int i; 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++) { for (i = 0; i < a->nr_args; i++) {
if ((b->nr_args <= i) || if ((b->nr_args <= i) ||
((a->args[i].type != b->args[i].type) || ((a->args[i].type != b->args[i].type) ||
......
...@@ -95,7 +95,7 @@ echo 'p:kprobes/testevent _do_fork abcd=\1' > kprobe_events ...@@ -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 ^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=\1:u8' # DIFF_ARG_TYPE
check_error 'p:kprobes/testevent _do_fork ^abcd=\"foo"' # 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 fi
exit 0 exit 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment