From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: David Carlier <devnexen@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6.y] tracing: Drop the synthetic event ref when clearing hist triggers
Date: Fri, 4 Dec 2026 07:03:43 -0500 [thread overview]
Message-ID: <20261204120322.2908974-1-sashal@kernel.org> (raw)
In-Reply-To: <2026120254-paternal-dimmer-9ae7@gregkh>
From: David Carlier <devnexen@gmail.com>
[ Upstream commit 2b3bed9617bb71c9b1893d9f54ef8df59a239224 ]
clear_event_triggers() frees a hist trigger on a synthetic event without
dropping the se->ref taken by event_hist_trigger_parse(). Removing an
instance with such a trigger leaves the synthetic event busy forever.
Cc: stable@vger.kernel.org
Fixes: 4b147936fa50 ("tracing: Add support for 'synthetic' events")
Link: https://patch.msgid.link/20261022205405.1228742-1-devnexen@gmail.com
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
[ sashal: Added the upstream hist_put_synth_event() call before the tree's existing data->ops->free(data) in clear_event_triggers(), since free is not reached through cmd_ops here. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/trace/trace.h | 2 ++
kernel/trace/trace_events_hist.c | 20 +++++++++++++-------
kernel/trace/trace_events_trigger.c | 2 ++
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 640257a8405d7..935d9077d71a1 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1599,9 +1599,11 @@ extern const struct file_operations event_inject_fops;
#ifdef CONFIG_HIST_TRIGGERS
extern int register_trigger_hist_cmd(void);
extern int register_trigger_hist_enable_disable_cmds(void);
+extern void hist_put_synth_event(struct trace_event_file *file);
#else
static inline int register_trigger_hist_cmd(void) { return 0; }
static inline int register_trigger_hist_enable_disable_cmds(void) { return 0; }
+static inline void hist_put_synth_event(struct trace_event_file *file) { }
#endif
extern int register_trigger_cmds(void);
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 0975d59cac2d1..41a896d334507 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -6725,6 +6725,17 @@ static bool hist_trigger_check_refs(struct event_trigger_data *data,
return false;
}
+void hist_put_synth_event(struct trace_event_file *file)
+{
+ struct synth_event *se;
+
+ lockdep_assert_held(&event_mutex);
+
+ se = find_synth_event_call(file->event_call);
+ if (se)
+ se->ref--;
+}
+
static void hist_unregister_trigger(char *glob,
struct event_trigger_data *data,
struct trace_event_file *file)
@@ -6780,7 +6791,6 @@ static void hist_unreg_all(struct trace_event_file *file)
{
struct event_trigger_data *test, *n;
struct hist_trigger_data *hist_data;
- struct synth_event *se;
lockdep_assert_held(&event_mutex);
@@ -6793,9 +6803,7 @@ static void hist_unreg_all(struct trace_event_file *file)
list_del_rcu(&test->list);
trace_event_trigger_enable_disable(file, 0);
- se = find_synth_event_call(file->event_call);
- if (se)
- se->ref--;
+ hist_put_synth_event(file);
update_cond_flag(file);
if (hist_data->enable_timestamps)
@@ -6910,9 +6918,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
}
event_trigger_unregister(cmd_ops, file, glob+1, trigger_data);
- se = find_synth_event_call(file->event_call);
- if (se)
- se->ref--;
+ hist_put_synth_event(file);
ret = 0;
goto out_free;
}
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index 3ef1fe15493d3..304ad15c8866b 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -516,6 +516,8 @@ clear_event_triggers(struct trace_array *tr)
list_for_each_entry_safe(data, n, &file->triggers, list) {
trace_event_trigger_enable_disable(file, 0);
list_del_rcu(&data->list);
+ if (data->cmd_ops->trigger_type == ETT_EVENT_HIST)
+ hist_put_synth_event(file);
if (data->ops->free)
data->ops->free(data);
}
--
2.53.0
prev parent reply other threads:[~2026-12-04 12:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 13:58 FAILED: patch "[PATCH] tracing: Drop the synthetic event ref when clearing hist" failed to apply to 6.6-stable tree gregkh
2026-12-04 12:03 ` Sasha Levin [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=20261204120322.2908974-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=devnexen@gmail.com \
--cc=rostedt@goodmis.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