]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ftrace: Fix regression with module command in stack_trace_filter
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 29 Jun 2017 14:05:45 +0000 (10:05 -0400)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 29 Jun 2017 14:05:45 +0000 (10:05 -0400)
When doing the following command:

 # echo ":mod:kvm_intel" > /sys/kernel/tracing/stack_trace_filter

it triggered a crash.

This happened with the clean up of probes. It required all callers to the
regex function (doing ftrace filtering) to have ops->private be a pointer to
a trace_array. But for the stack tracer, that is not the case.

Allow for the ops->private to be NULL, and change the function command
callbacks to handle the trace_array pointer being NULL as well.

Fixes: d2afd57a4b96 ("tracing/ftrace: Allow instances to have their own function probes")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/ftrace.c
kernel/trace/trace.c
kernel/trace/trace_functions.c
kernel/trace/trace_stack.c

index 9e5841dc14b5fa62e0c1470df704c3dc9b99f8ad..b308be30dfb9b93307305a9c47d2156f6d90600a 100644 (file)
@@ -4337,9 +4337,6 @@ static int ftrace_process_regex(struct ftrace_iterator *iter,
 
        command = strsep(&next, ":");
 
-       if (WARN_ON_ONCE(!tr))
-               return -EINVAL;
-
        mutex_lock(&ftrace_cmd_mutex);
        list_for_each_entry(p, &ftrace_commands, list) {
                if (strcmp(p->name, command) == 0) {
index 1122f151466f64425089b9b9ecbd4b1a7584ba8a..091e801145c9996812fbaedafae1e912c123ecd7 100644 (file)
@@ -6881,6 +6881,9 @@ ftrace_trace_snapshot_callback(struct trace_array *tr, struct ftrace_hash *hash,
        char *number;
        int ret;
 
+       if (!tr)
+               return -ENODEV;
+
        /* hash funcs only work with set_ftrace_filter */
        if (!enable)
                return -EINVAL;
index a3bddbfd0874a26bcdbc84b3b4713cb206a0998b..a0910c0cdf2eabfa690d7cf434a5467faa5e01e4 100644 (file)
@@ -654,6 +654,9 @@ ftrace_trace_onoff_callback(struct trace_array *tr, struct ftrace_hash *hash,
 {
        struct ftrace_probe_ops *ops;
 
+       if (!tr)
+               return -ENODEV;
+
        /* we register both traceon and traceoff to this callback */
        if (strcmp(cmd, "traceon") == 0)
                ops = param ? &traceon_count_probe_ops : &traceon_probe_ops;
@@ -670,6 +673,9 @@ ftrace_stacktrace_callback(struct trace_array *tr, struct ftrace_hash *hash,
 {
        struct ftrace_probe_ops *ops;
 
+       if (!tr)
+               return -ENODEV;
+
        ops = param ? &stacktrace_count_probe_ops : &stacktrace_probe_ops;
 
        return ftrace_trace_probe_callback(tr, ops, hash, glob, cmd,
@@ -682,6 +688,9 @@ ftrace_dump_callback(struct trace_array *tr, struct ftrace_hash *hash,
 {
        struct ftrace_probe_ops *ops;
 
+       if (!tr)
+               return -ENODEV;
+
        ops = &dump_probe_ops;
 
        /* Only dump once. */
@@ -695,6 +704,9 @@ ftrace_cpudump_callback(struct trace_array *tr, struct ftrace_hash *hash,
 {
        struct ftrace_probe_ops *ops;
 
+       if (!tr)
+               return -ENODEV;
+
        ops = &cpudump_probe_ops;
 
        /* Only dump once. */
index 76aa04d4c9257482181c9b2885530fb4dc417edd..b4a751e8f9d69763c1d1fbd10083819b50db3ab4 100644 (file)
@@ -409,7 +409,9 @@ static const struct file_operations stack_trace_fops = {
 static int
 stack_trace_filter_open(struct inode *inode, struct file *file)
 {
-       return ftrace_regex_open(&trace_ops, FTRACE_ITER_FILTER,
+       struct ftrace_ops *ops = inode->i_private;
+
+       return ftrace_regex_open(ops, FTRACE_ITER_FILTER,
                                 inode, file);
 }
 
@@ -476,7 +478,7 @@ static __init int stack_trace_init(void)
                        NULL, &stack_trace_fops);
 
        trace_create_file("stack_trace_filter", 0444, d_tracer,
-                       NULL, &stack_trace_filter_fops);
+                         &trace_ops, &stack_trace_filter_fops);
 
        if (stack_trace_filter_buf[0])
                ftrace_set_early_filter(&trace_ops, stack_trace_filter_buf, 1);