]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ftrace: Fix regression with module command in stack_trace_filter
authorguoweikang <guoweikang.kernel@gmail.com>
Wed, 20 Nov 2024 05:27:49 +0000 (13:27 +0800)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 20 Nov 2024 16:15:29 +0000 (11:15 -0500)
When executing the following command:

    # echo "write*:mod:ext3" > /sys/kernel/tracing/stack_trace_filter

The current mod command causes a null pointer dereference. While commit
0f17976568b3f ("ftrace: Fix regression with module command in stack_trace_filter")
has addressed part of the issue, it left a corner case unhandled, which still
results in a kernel crash.

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/20241120052750.275463-1-guoweikang.kernel@gmail.com
Fixes: 04ec7bb642b77 ("tracing: Have the trace_array hold the list of registered func probes");
Signed-off-by: guoweikang <guoweikang.kernel@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/ftrace.c

index 4c28dd177ca650686d92895b7614ada665d6cf86..5ff0822342acf31deae954c82135fd63c888530a 100644 (file)
@@ -5076,6 +5076,9 @@ ftrace_mod_callback(struct trace_array *tr, struct ftrace_hash *hash,
        char *func;
        int ret;
 
+       if (!tr)
+               return -ENODEV;
+
        /* match_records() modifies func, and we need the original */
        func = kstrdup(func_orig, GFP_KERNEL);
        if (!func)