mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	stable@vger.kernel.org, David Carlier <devnexen@gmail.com>
Subject: [for-next][PATCH 2/6] tracing: Hold trace_types_lock when updating modules in persistent instances
Date: Tue, 20 Oct 2026 08:19:58 -0400	[thread overview]
Message-ID: <20261020122010.817062532@kernel.org> (raw)
In-Reply-To: <20261020121956.600452831@kernel.org>

From: David Carlier <devnexen@gmail.com>

trace_module_record() walks ftrace_trace_arrays from the module notifier
without trace_types_lock. A concurrent rmdir of an instance removes it
from the list and frees it under that lock, so a module load or unload
can walk into a freed trace_array.

Cc: stable@vger.kernel.org
Fixes: 5f3719f697c3 ("tracing: Update modules to persistent instances when loaded")
Link: https://patch.msgid.link/20261016061638.214847-1-devnexen@gmail.com
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 48ecc4bb55e4..96005a930b25 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -9244,6 +9244,8 @@ static void trace_module_record(struct module *mod, bool add)
 	struct trace_array *tr;
 	unsigned long flags;
 
+	guard(mutex)(&trace_types_lock);
+
 	list_for_each_entry(tr, &ftrace_trace_arrays, list) {
 		flags = tr->flags & (TRACE_ARRAY_FL_BOOT | TRACE_ARRAY_FL_LAST_BOOT);
 		/* Update any persistent trace array that has already been started */
-- 
2.53.0

  parent reply	other threads:[~2026-10-20 12:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 12:19 [for-next][PATCH 0/6] tracing: Updates for 7.4 Steven Rostedt
2026-10-20 12:19 ` [for-next][PATCH 1/6] tracing/syscalls: Use copy_from_user for the faultable syscall buffer Steven Rostedt
2026-10-20 12:19 ` Steven Rostedt [this message]
2026-10-20 12:19 ` [for-next][PATCH 3/6] tracing: Hold trace_types_lock when resetting last boot data from readers Steven Rostedt
2026-10-20 12:20 ` [for-next][PATCH 4/6] tracing: Save the event file instead of the compatible histogram Steven Rostedt
2026-10-20 12:20 ` [for-next][PATCH 5/6] tracing/histograms: Verify event_call identity when updating synth_event refcount Steven Rostedt
2026-10-20 12:20 ` [for-next][PATCH 6/6] tracing/osnoise: Add __printf attribute to osnoise_print() 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=20261020122010.817062532@kernel.org \
    --to=rostedt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=devnexen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --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

all inboxes | Powered by JetHome®