All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	stable@vger.kernel.org, Kamal Agrawal <kamaagra@codeaurora.org>
Subject: [for-linus][PATCH 1/6] tracing: Fix NULL pointer dereference in start_creating
Date: Thu, 05 Aug 2021 11:43:37 -0400	[thread overview]
Message-ID: <20210805154935.553422403@goodmis.org> (raw)
In-Reply-To: 20210805154336.208362117@goodmis.org

From: Kamal Agrawal <kamaagra@codeaurora.org>

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

Link: https://lkml.kernel.org/r/1627651386-21315-1-git-send-email-kamaagra@codeaurora.org

Cc: stable@vger.kernel.org
Fixes: 4114fbfd02f1 ("tracing: Enable creating new instance early boot")
Signed-off-by: Kamal Agrawal <kamaagra@codeaurora.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.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 c59dd35a6da5..33899a71fdc1 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);
-- 
2.30.2

  reply	other threads:[~2021-08-05 15:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05 15:43 [for-linus][PATCH 0/6] tracing: Fixes for 5.14-rc4 Steven Rostedt
2021-08-05 15:43 ` Steven Rostedt [this message]
2021-08-05 15:43 ` [for-linus][PATCH 2/6] tracing / histogram: Give calculation hist_fields a size Steven Rostedt
2021-08-05 15:43 ` [for-linus][PATCH 3/6] tracing: Reject string operand in the histogram expression Steven Rostedt
2021-08-05 15:43 ` [for-linus][PATCH 4/6] scripts/recordmcount.pl: Remove check_objcopy() and $can_use_local Steven Rostedt
2021-08-05 15:43 ` [for-linus][PATCH 5/6] scripts/tracing: fix the bug that cant parse raw_trace_func Steven Rostedt
2021-08-05 15:43 ` [for-linus][PATCH 6/6] tracing: Quiet smp_processor_id() use in preemptable warning in hwlat Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210805154935.553422403@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=kamaagra@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.