From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Tom Zanussi <zanussi@kernel.org>, Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v5 2/6] tracing: Fix to check event_mutex is held while accessing trigger list
Date: Sun, 4 Sep 2022 13:12:29 +0900 [thread overview]
Message-ID: <166226474977.223837.1992182913048377113.stgit@devnote2> (raw)
In-Reply-To: <166226473132.223837.9011128463174539022.stgit@devnote2>
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().
Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.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;
next prev parent reply other threads:[~2022-09-04 4:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-04 4:12 [PATCH v5 0/6] tracing/hist: Add percentage histogram suffixes Masami Hiramatsu (Google)
2022-09-04 4:12 ` [PATCH v5 1/6] tracing: Allow multiple hitcount values in histograms Masami Hiramatsu (Google)
2022-09-07 2:03 ` Steven Rostedt
2022-09-07 6:12 ` Masami Hiramatsu
2022-09-04 4:12 ` Masami Hiramatsu (Google) [this message]
2022-09-07 2:09 ` [PATCH v5 2/6] tracing: Fix to check event_mutex is held while accessing trigger list Steven Rostedt
2022-09-04 4:12 ` [PATCH v5 3/6] tracing: Add .percent suffix option to histogram values Masami Hiramatsu (Google)
2022-09-04 4:12 ` [PATCH v5 4/6] tracing: Add .graph suffix option to histogram value Masami Hiramatsu (Google)
2022-09-04 4:12 ` [PATCH v5 5/6] tracing: Add nohitcount option for suppressing display of raw hitcount Masami Hiramatsu (Google)
2022-09-04 4:13 ` [PATCH v5 6/6] tracing: docs: Update histogram doc for .percent/.graph and 'nohitcount' Masami Hiramatsu (Google)
2022-09-08 22:01 ` [PATCH v5 0/6] tracing/hist: Add percentage histogram suffixes Tom Zanussi
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=166226474977.223837.1992182913048377113.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=zanussi@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 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.