From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Daniil Dulov <d.dulov@aladdin.ru>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
"open list:TRACING" <linux-kernel@vger.kernel.org>,
"open list:TRACING" <linux-trace-kernel@vger.kernel.org>,
<lvc-project@linuxtesting.org>,
"kernel test robot" <lkp@intel.com>,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH] ring-buffer: Fix possible dereference of uninitialized pointer
Date: Mon, 16 Feb 2026 17:00:01 +0900 [thread overview]
Message-ID: <20260216170001.f6d362ab74f47d2e888b4947@kernel.org> (raw)
In-Reply-To: <20260213100130.2013839-1-d.dulov@aladdin.ru>
On Fri, 13 Feb 2026 13:01:30 +0300
Daniil Dulov <d.dulov@aladdin.ru> wrote:
> There is a pointer head_page in rb_meta_validate_events() which is not
> initialized at the beginning of a function. This pointer can be dereferenced
> if there is a failure during reader page validation. In this case the control
> is passed to "invalid" label where the pointer is dereferenced in a loop.
>
> To fix the issue initialize orig_head and head_page before calling
> rb_validate_buffer.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thanks!
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202406130130.JtTGRf7W-lkp@intel.com/
> Fixes: 5f3b6e839f3c ("ring-buffer: Validate boot range memory events")
> Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
> ---
> kernel/trace/ring_buffer.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index 630221b00838..ad08430347b0 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -1918,6 +1918,8 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
> if (!meta || !meta->head_buffer)
> return;
>
> + orig_head = head_page = cpu_buffer->head_page;
> +
> /* Do the reader page first */
> ret = rb_validate_buffer(cpu_buffer->reader_page->page, cpu_buffer->cpu);
> if (ret < 0) {
> @@ -1928,7 +1930,6 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
> entry_bytes += local_read(&cpu_buffer->reader_page->page->commit);
> local_set(&cpu_buffer->reader_page->entries, ret);
>
> - orig_head = head_page = cpu_buffer->head_page;
> ts = head_page->page->time_stamp;
>
> /*
> --
> 2.34.1
>
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2026-02-16 8:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-13 10:01 [PATCH] ring-buffer: Fix possible dereference of uninitialized pointer Daniil Dulov
2026-02-16 8:00 ` Masami Hiramatsu [this message]
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=20260216170001.f6d362ab74f47d2e888b4947@kernel.org \
--to=mhiramat@kernel.org \
--cc=d.dulov@aladdin.ru \
--cc=dan.carpenter@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=lvc-project@linuxtesting.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox