diff mbox series

ftrace: Fix regression with module command in stack_trace_filter

Message ID 20241120052750.275463-1-guoweikang.kernel@gmail.com (mailing list archive)
State Queued
Commit 45af52e7d3b8560f21d139b3759735eead8b1653
Headers show
Series ftrace: Fix regression with module command in stack_trace_filter | expand

Commit Message

guoweikang Nov. 20, 2024, 5:27 a.m. UTC
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.

Signed-off-by: guoweikang <guoweikang.kernel@gmail.com>
---
 kernel/trace/ftrace.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Steven Rostedt Nov. 20, 2024, 2:52 p.m. UTC | #1
On Wed, 20 Nov 2024 13:27:49 +0800
guoweikang <guoweikang.kernel@gmail.com> wrote:

> 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.

Ouch!

Thanks, I'll also mark this as stable.

-- Steve

> 
> Signed-off-by: guoweikang <guoweikang.kernel@gmail.com>
> ---
>  kernel/trace/ftrace.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 71e53eaba8bc..9b17efb1a87d 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -5093,6 +5093,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)
diff mbox series

Patch

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 71e53eaba8bc..9b17efb1a87d 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5093,6 +5093,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)