Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH] tracing: Fix trace_event_file leak on read-only instances
@ 2026-11-26 21:45 David Carlier
  0 siblings, 0 replies; only message in thread
From: David Carlier @ 2026-11-26 21:45 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: Mathieu Desnoyers, linux-trace-kernel, linux-kernel,
	David Carlier, stable

event_create_dir() takes a reference on the trace_event_file that is
dropped by the release callback of the "enable" eventfs entry. A
read-only (backup) instance only registers the first
NR_RO_EVENT_ENTRIES entries, so release_ei() never reaches that
callback and every trace_event_file of the instance is leaked when it
is removed.

Move the release callback to the "format" entry, which all instances
have.

Fixes: 2c79da099aac ("tracing: Make the backup instance non-reusable")
Cc: stable@vger.kernel.org # 7.1+
Signed-off-by: David Carlier <devnexen@gmail.com>
---
 kernel/trace/trace_events.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 7f89160aeff3..b3f63b1f86e0 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -3276,7 +3276,7 @@ static int event_callback(const char *name, umode_t *mode, void **data,
 	return 0;
 }
 
-/* The file is incremented on creation and freeing the enable file decrements it */
+/* The file is incremented on creation and freeing the event directory decrements it */
 static void event_release(const char *name, void *data)
 {
 	struct trace_event_file *file = data;
@@ -3298,6 +3298,7 @@ event_create_dir(struct eventfs_inode *parent, struct trace_event_file *file)
 		{
 			.name		= "format",
 			.callback	= event_callback,
+			.release	= event_release,
 		},
 #ifdef CONFIG_PERF_EVENTS
 		{
@@ -3317,7 +3318,6 @@ event_create_dir(struct eventfs_inode *parent, struct trace_event_file *file)
 		{
 			.name		= "enable",
 			.callback	= event_callback,
-			.release	= event_release,
 		},
 		{
 			.name		= "filter",
@@ -3380,7 +3380,7 @@ event_create_dir(struct eventfs_inode *parent, struct trace_event_file *file)
 
 	file->ei = ei;
 
-	/* Gets decremented on freeing of the "enable" file */
+	/* Gets decremented by event_release() when the ei is freed */
 	event_file_get(file);
 
 	return 0;
-- 
2.55.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-26 21:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 21:45 [PATCH] tracing: Fix trace_event_file leak on read-only instances David Carlier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox