mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Roland Ruckerbauer <roland.rucky@gmail.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org, Takashi Iwai <tiwai@suse.de>,
	regressions@lists.linux.dev,
	Steven Noonan <steven.noonan@gmail.com>
Subject: Re: [BUG] NULL pointer dereference probably caused by kernel/trace/ring_buffer.c
Date: Tue, 1 Nov 2022 18:43:47 -0400	[thread overview]
Message-ID: <20221101184347.2ecce20c@rorschach.local.home> (raw)
In-Reply-To: <20221101183512.285cfd68@rorschach.local.home>

On Tue, 1 Nov 2022 18:35:12 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> OK, this is a great clue. I'll dig deeper.

One more NULL check. And this one is legit, and I'm betting is the fix.

The buffer->buffers is allocated to nr_cpu_ids, but are only
initialized for online CPUs. If you have a CPU that is not yet
initialized (or may never be), then the cpu_buffer will be NULL.

-- Steve

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 199759c73519..4ffcc6e33258 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -937,6 +937,9 @@ void ring_buffer_wake_waiters(struct trace_buffer *buffer, int cpu)
 	struct ring_buffer_per_cpu *cpu_buffer;
 	struct rb_irq_work *rbwork;
 
+	if (!buffer)
+		return;
+
 	if (cpu == RING_BUFFER_ALL_CPUS) {
 
 		/* Wake up individual ones too. One level recursion */
@@ -945,7 +948,14 @@ void ring_buffer_wake_waiters(struct trace_buffer *buffer, int cpu)
 
 		rbwork = &buffer->irq_work;
 	} else {
+		if (WARN_ON_ONCE(!buffer->buffers))
+			return;
+		if (WARN_ON_ONCE(cpu >= nr_cpu_ids))
+			return;
 		cpu_buffer = buffer->buffers[cpu];
+		/* The CPU buffer may not have been initialized yet */
+		if (!cpu_buffer)
+			return;
 		rbwork = &cpu_buffer->irq_work;
 	}
 

  reply	other threads:[~2022-11-01 22:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 13:02 Roland Ruckerbauer
2022-10-31 13:24 ` Steven Rostedt
2022-10-31 18:50 ` Steven Rostedt
2022-10-31 20:20   ` Roland Ruckerbauer
2022-11-01 19:31     ` Steven Rostedt
2022-11-01 20:07       ` Roland Ruckerbauer
2022-11-01 21:38         ` Steven Rostedt
2022-11-01 21:50           ` Roland Ruckerbauer
2022-11-01 22:01             ` Roland Ruckerbauer
2022-11-01 22:35               ` Steven Rostedt
2022-11-01 22:43                 ` Steven Rostedt [this message]
2022-11-01 23:00                   ` Roland Ruckerbauer

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=20221101184347.2ecce20c@rorschach.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=regressions@lists.linux.dev \
    --cc=roland.rucky@gmail.com \
    --cc=steven.noonan@gmail.com \
    --cc=tiwai@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®