From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
stable@vger.kernel.org,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Subject: [for-linus][PATCH 6/7] tracing: Fix to check event_mutex is held while accessing trigger list
Date: Wed, 07 Sep 2022 12:15:17 -0400 [thread overview]
Message-ID: <20220907161610.282974054@goodmis.org> (raw)
In-Reply-To: 20220907161511.694486342@goodmis.org
From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Since the check_user_trigger() is called outside of RCU
read lock, this list_for_each_entry_rcu() caused a suspicious
RCU usage warning.
# echo hist:keys=pid > events/sched/sched_stat_runtime/trigger
# cat events/sched/sched_stat_runtime/trigger
[ 43.167032]
[ 43.167418] =============================
[ 43.167992] WARNING: suspicious RCU usage
[ 43.168567] 5.19.0-rc5-00029-g19ebe4651abf #59 Not tainted
[ 43.169283] -----------------------------
[ 43.169863] kernel/trace/trace_events_trigger.c:145 RCU-list traversed in non-reader section!!
...
However, this file->triggers list is safe when it is accessed
under event_mutex is held.
To fix this warning, adds a lockdep_is_held check to the
list_for_each_entry_rcu().
Link: https://lkml.kernel.org/r/166226474977.223837.1992182913048377113.stgit@devnote2
Cc: stable@vger.kernel.org
Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/trace_events_trigger.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index cb866c3141af..918730d74932 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -142,7 +142,8 @@ static bool check_user_trigger(struct trace_event_file *file)
{
struct event_trigger_data *data;
- list_for_each_entry_rcu(data, &file->triggers, list) {
+ list_for_each_entry_rcu(data, &file->triggers, list,
+ lockdep_is_held(&event_mutex)) {
if (data->flags & EVENT_TRIGGER_FL_PROBE)
continue;
return true;
--
2.35.1
next prev parent reply other threads:[~2022-09-07 16:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 16:15 [for-linus][PATCH 0/7] tracing: Fixes and updates for 6.0 Steven Rostedt
2022-09-07 16:15 ` [for-linus][PATCH 1/7] rv/monitors: Make monitors automata definition static Steven Rostedt
2022-09-07 16:15 ` [for-linus][PATCH 2/7] MAINTAINERS: Add Runtime Verification (RV) entry Steven Rostedt
2022-09-07 16:15 ` [for-linus][PATCH 3/7] MAINTAINERS: add scripts/tracing/ to TRACING Steven Rostedt
2022-09-07 16:15 ` [for-linus][PATCH 4/7] tracepoint: Allow trace events in modules with TAINT_TEST Steven Rostedt
2022-09-07 16:15 ` [for-linus][PATCH 5/7] tracing: hold caller_addr to hardirq_{enable,disable}_ip Steven Rostedt
2022-09-07 16:15 ` Steven Rostedt [this message]
2022-09-07 16:15 ` [for-linus][PATCH 7/7] rv/reactor: add __init/__exit annotations to module init/exit funcs 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=20220907161610.282974054@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@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