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
Subject: [for-linus][PATCH 2/7] ftrace: Check for empty hash and comment the race with registering probes
Date: Sat, 31 Aug 2019 06:53:31 -0400 [thread overview]
Message-ID: <20190831105410.061248409@goodmis.org> (raw)
In-Reply-To: 20190831105329.122820332@goodmis.org
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
The race between adding a function probe and reading the probes that exist
is very subtle. It needs a comment. Also, the issue can also happen if the
probe has has the EMPTY_HASH as its func_hash.
Cc: stable@vger.kernel.org
Fixes: 7b60f3d876156 ("ftrace: Dynamically create the probe ftrace_ops for the trace_array")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 80beed2cf0da..6200a6fe10e3 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3096,7 +3096,11 @@ t_probe_next(struct seq_file *m, loff_t *pos)
hash = iter->probe->ops.func_hash->filter_hash;
- if (!hash)
+ /*
+ * A probe being registered may temporarily have an empty hash
+ * and it's at the end of the func_probes list.
+ */
+ if (!hash || hash == EMPTY_HASH)
return NULL;
size = 1 << hash->size_bits;
@@ -4324,6 +4328,10 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,
mutex_unlock(&ftrace_lock);
+ /*
+ * Note, there's a small window here that the func_hash->filter_hash
+ * may be NULL or empty. Need to be carefule when reading the loop.
+ */
mutex_lock(&probe->ops.func_hash->regex_lock);
orig_hash = &probe->ops.func_hash->filter_hash;
--
2.20.1
next prev parent reply other threads:[~2019-08-31 10:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-31 10:53 [for-linus][PATCH 0/7] tracing: Updates for 5.3 Steven Rostedt
2019-08-31 10:53 ` [for-linus][PATCH 1/7] ftrace: Fix NULL pointer dereference in t_probe_next() Steven Rostedt
2019-08-31 10:53 ` Steven Rostedt [this message]
2019-08-31 10:53 ` [for-linus][PATCH 3/7] ftrace: Check for successful allocation of hash Steven Rostedt
2019-08-31 10:53 ` [for-linus][PATCH 4/7] tracing: Make exported ftrace_set_clr_event non-static Steven Rostedt
2019-08-31 10:53 ` [for-linus][PATCH 5/7] tracing/probe: Fix null pointer dereference Steven Rostedt
2019-08-31 10:53 ` [for-linus][PATCH 6/7] ftrace/x86: Remove mcount() declaration Steven Rostedt
2019-08-31 10:53 ` [for-linus][PATCH 7/7] tracing: Correct kdoc formats 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=20190831105410.061248409@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.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