linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing: Fix NULL pointer dereference in start_creating
@ 2021-07-30 13:23 Kamal Agrawal
  2021-07-30 22:41 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Kamal Agrawal @ 2021-07-30 13:23 UTC (permalink / raw)
  To: rostedt, mingo, linux-kernel, mhiramat; +Cc: linux-arm-msm

The event_trace_add_tracer() can fail. In this case, it leads to a crash
in start_creating with below call stack. Handle the error scenario
properly in trace_array_create_dir.

Call trace:
down_write+0x7c/0x204
start_creating.25017+0x6c/0x194
tracefs_create_file+0xc4/0x2b4
init_tracer_tracefs+0x5c/0x940
trace_array_create_dir+0x58/0xb4
trace_array_create+0x1bc/0x2b8
trace_array_get_by_name+0xdc/0x18c

Fixes: 4114fbfd
Signed-off-by: Kamal Agrawal <kamaagra@codeaurora.org>
---
 kernel/trace/trace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c59dd35..33899a7 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -9135,8 +9135,10 @@ static int trace_array_create_dir(struct trace_array *tr)
 		return -EINVAL;
 
 	ret = event_trace_add_tracer(tr->dir, tr);
-	if (ret)
+	if (ret) {
 		tracefs_remove(tr->dir);
+		return ret;
+	}
 
 	init_tracer_tracefs(tr, tr->dir);
 	__update_tracer_options(tr);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation.


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

* Re: [PATCH] tracing: Fix NULL pointer dereference in start_creating
  2021-07-30 13:23 [PATCH] tracing: Fix NULL pointer dereference in start_creating Kamal Agrawal
@ 2021-07-30 22:41 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2021-07-30 22:41 UTC (permalink / raw)
  To: Kamal Agrawal; +Cc: mingo, linux-kernel, mhiramat, linux-arm-msm

On Fri, 30 Jul 2021 18:53:06 +0530
Kamal Agrawal <kamaagra@codeaurora.org> wrote:

> The event_trace_add_tracer() can fail. In this case, it leads to a crash
> in start_creating with below call stack. Handle the error scenario
> properly in trace_array_create_dir.
> 
> Call trace:
> down_write+0x7c/0x204
> start_creating.25017+0x6c/0x194
> tracefs_create_file+0xc4/0x2b4
> init_tracer_tracefs+0x5c/0x940
> trace_array_create_dir+0x58/0xb4
> trace_array_create+0x1bc/0x2b8
> trace_array_get_by_name+0xdc/0x18c
> 
> Fixes: 4114fbfd

Thanks, I'll queue this up.

-- Steve

> Signed-off-by: Kamal Agrawal <kamaagra@codeaurora.org>
> ---
>  kernel/trace/trace.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index c59dd35..33899a7 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -9135,8 +9135,10 @@ static int trace_array_create_dir(struct trace_array *tr)
>  		return -EINVAL;
>  
>  	ret = event_trace_add_tracer(tr->dir, tr);
> -	if (ret)
> +	if (ret) {
>  		tracefs_remove(tr->dir);
> +		return ret;
> +	}
>  
>  	init_tracer_tracefs(tr, tr->dir);
>  	__update_tracer_options(tr);


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

end of thread, other threads:[~2021-07-30 22:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 13:23 [PATCH] tracing: Fix NULL pointer dereference in start_creating Kamal Agrawal
2021-07-30 22:41 ` 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).