public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	stable@vger.kernel.org,
	Daniil Tatianin <d-tatianin@yandex-team.ru>
Subject: [for-linus][PATCH 07/13] ring_buffer: Do not deactivate non-existant pages
Date: Sun, 20 Nov 2022 15:07:07 -0500	[thread overview]
Message-ID: <20221120200734.530770096@goodmis.org> (raw)
In-Reply-To: 20221120200700.725968899@goodmis.org

From: Daniil Tatianin <d-tatianin@yandex-team.ru>

rb_head_page_deactivate() expects cpu_buffer to contain a valid list of
->pages, so verify that the list is actually present before calling it.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Link: https://lkml.kernel.org/r/20221114143129.3534443-1-d-tatianin@yandex-team.ru

Cc: stable@vger.kernel.org
Fixes: 77ae365eca895 ("ring-buffer: make lockless")
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/ring_buffer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index a19369c4d8df..b21bf14bae9b 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1802,9 +1802,9 @@ static void rb_free_cpu_buffer(struct ring_buffer_per_cpu *cpu_buffer)
 
 	free_buffer_page(cpu_buffer->reader_page);
 
-	rb_head_page_deactivate(cpu_buffer);
-
 	if (head) {
+		rb_head_page_deactivate(cpu_buffer);
+
 		list_for_each_entry_safe(bpage, tmp, head, list) {
 			list_del_init(&bpage->list);
 			free_buffer_page(bpage);
-- 
2.35.1



  parent reply	other threads:[~2022-11-20 20:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20 20:07 [for-linus][PATCH 00/13] tracing: Fixes for 6.1 Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 01/13] tracing/ring-buffer: Have polling block on watermark Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 02/13] ring-buffer: Include dropped pages in counting dirty patches Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 03/13] tracing: Fix memory leak in tracing_read_pipe() Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 04/13] tracing: Fix warning on variable struct trace_array Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 05/13] ftrace: Fix the possible incorrect kernel message Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 06/13] ftrace: Optimize the allocation for mcount entries Steven Rostedt
2022-11-20 20:07 ` Steven Rostedt [this message]
2022-11-20 20:07 ` [for-linus][PATCH 08/13] ftrace: Fix null pointer dereference in ftrace_add_mod() Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 09/13] tracing: Fix memory leak in test_gen_synth_cmd() and test_empty_synth_event() Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 10/13] tracing: Fix wild-memory-access in register_synth_event() Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 11/13] tracing: Remove unused __bad_type_size() method Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 12/13] tracing: Fix potential null-pointer-access of entry in list tr->err_log Steven Rostedt
2022-11-20 20:07 ` [for-linus][PATCH 13/13] tracing: Fix race where eprobes can be called before the event 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=20221120200734.530770096@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=d-tatianin@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox