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>,
syzbot+ccdec3bfe0beec58a38d@syzkaller.appspotmail.com
Subject: [for-linus][PATCH 01/15] tracing: Fix enabling of tracing on file release
Date: Fri, 05 Dec 2025 20:06:34 -0500 [thread overview]
Message-ID: <20251206010700.815241948@kernel.org> (raw)
In-Reply-To: 20251206010633.884804695@kernel.org
From: Steven Rostedt <rostedt@goodmis.org>
The trace file will pause tracing if the tracing instance has the
"pause-on-trace" option is set. This happens when the file is opened, and
it is unpaused when the file is closed. When this was first added, there
was only one user that paused tracing. On open, the check to pause was:
if (!iter->snapshot && (tr->trace_flags & TRACE_ITER(PAUSE_ON_TRACE)))
Where if it is not the snapshot tracer and the "pause-on-trace" option is
set, then it increments a "stop_count" of the trace instance.
On close, the check is:
if (!iter->snapshot && tr->stop_count)
That is, if it is not the snapshot buffer and it was stopped, it will
re-enable tracing.
Now there's more places that stop tracing. This means, if something else
stops tracing the tr->stop_count will be non-zero, and that means if the
trace file is closed, it will decrement the stop_count even though it
never incremented it. This causes a warning because when the user that
stopped tracing enables it again, the stop_count goes below zero.
Instead of relying on the stop_count being set to know if the close of
the trace file should enable tracing again, add a new flag to the trace
iterator. The trace iterator is unique per open of the trace file, and if
the open stops tracing set the trace iterator PAUSE flag. On close, if the
PAUSE flag is set, then re-enable it again.
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/20251202161751.24abaaf1@gandalf.local.home
Fixes: 06e0a548bad0f ("tracing: Do not disable tracing when reading the trace file")
Reported-by: syzbot+ccdec3bfe0beec58a38d@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/692f44a5.a70a0220.2ea503.00c8.GAE@google.com/
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
include/linux/trace_events.h | 1 +
kernel/trace/trace.c | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 04307a19cde3..3690221ba3d8 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -138,6 +138,7 @@ enum trace_iter_flags {
TRACE_FILE_LAT_FMT = 1,
TRACE_FILE_ANNOTATE = 2,
TRACE_FILE_TIME_IN_NS = 4,
+ TRACE_FILE_PAUSE = 8,
};
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c9fbb316dcbd..cf725a33d99c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4709,8 +4709,10 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot)
* If pause-on-trace is enabled, then stop the trace while
* dumping, unless this is the "snapshot" file
*/
- if (!iter->snapshot && (tr->trace_flags & TRACE_ITER(PAUSE_ON_TRACE)))
+ if (!iter->snapshot && (tr->trace_flags & TRACE_ITER(PAUSE_ON_TRACE))) {
+ iter->iter_flags |= TRACE_FILE_PAUSE;
tracing_stop_tr(tr);
+ }
if (iter->cpu_file == RING_BUFFER_ALL_CPUS) {
for_each_tracing_cpu(cpu) {
@@ -4842,7 +4844,7 @@ static int tracing_release(struct inode *inode, struct file *file)
if (iter->trace && iter->trace->close)
iter->trace->close(iter);
- if (!iter->snapshot && tr->stop_count)
+ if (iter->iter_flags & TRACE_FILE_PAUSE)
/* reenable tracing if it was previously enabled */
tracing_start_tr(tr);
--
2.51.0
next prev parent reply other threads:[~2025-12-06 1:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-06 1:06 [for-linus][PATCH 00/15] tracing: Fixes for v6.19 Steven Rostedt
2025-12-06 1:06 ` Steven Rostedt [this message]
2025-12-06 1:06 ` [for-linus][PATCH 02/15] tracing: Fix fixed array of synthetic event Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 03/15] tracing: Fix typo in fpgraph.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 04/15] tracing: Fix typo in fprobe.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 05/15] tracing: Fix multiple typos in ring_buffer.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 06/15] tracing: Fix typo in ring_buffer_benchmark.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 07/15] tracing: Fix multiple typos in trace.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 08/15] tracing: Fix multiple typos in trace_events.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 09/15] tracing: Fix typo in trace_events_filter.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 10/15] tracing: Fix typo in trace_events_hist.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 11/15] tracing: Fix typo in trace_events_trigger.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 12/15] tracing: Fix multiple typos in trace_events_user.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 13/15] tracing: Fix multiple typos in trace_osnoise.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 14/15] tracing: Fix typo in trace_probe.c Steven Rostedt
2025-12-06 1:06 ` [for-linus][PATCH 15/15] tracing: Fix typo in trace_seq.c 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=20251206010700.815241948@kernel.org \
--to=rostedt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=syzbot+ccdec3bfe0beec58a38d@syzkaller.appspotmail.com \
/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