* [PATCH] tracing: Fix trace_event_file leak on read-only instances
@ 2026-11-26 21:45 David Carlier
2026-12-01 21:00 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread
* Re: [PATCH] tracing: Fix trace_event_file leak on read-only instances
2026-11-26 21:45 [PATCH] tracing: Fix trace_event_file leak on read-only instances David Carlier
@ 2026-12-01 21:00 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2026-12-01 21:00 UTC (permalink / raw)
To: David Carlier
Cc: Masami Hiramatsu, Mathieu Desnoyers, linux-trace-kernel,
linux-kernel, stable
On Thu, 26 Nov 2026 21:45:44 +0000
David Carlier <devnexen@gmail.com> wrote:
> 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 */
The above should replace "enable" with "filter" because that's what you
did. You just removed the comment that says what actually releases this
descriptor.
-- Steve
> event_file_get(file);
>
> return 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-01 21:01 UTC | newest]
Thread overview: 2+ messages (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
2026-12-01 21:00 ` Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.