linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ftrace: Fix regression with module command in stack_trace_filter
@ 2024-11-20  5:27 guoweikang
  2024-11-20 14:52 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: guoweikang @ 2024-11-20  5:27 UTC (permalink / raw)
  To: rostedt, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers
  Cc: guoweikang, linux-kernel, linux-trace-kernel

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(+)

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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ftrace: Fix regression with module command in stack_trace_filter
  2024-11-20  5:27 [PATCH] ftrace: Fix regression with module command in stack_trace_filter guoweikang
@ 2024-11-20 14:52 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2024-11-20 14:52 UTC (permalink / raw)
  To: guoweikang
  Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel

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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-20 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-20  5:27 [PATCH] ftrace: Fix regression with module command in stack_trace_filter guoweikang
2024-11-20 14:52 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).