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,
"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Subject: [for-linus][PATCH 3/7] ftrace: Check for successful allocation of hash
Date: Sat, 31 Aug 2019 06:53:32 -0400 [thread overview]
Message-ID: <20190831105410.217140090@goodmis.org> (raw)
In-Reply-To: 20190831105329.122820332@goodmis.org
From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
In register_ftrace_function_probe(), we are not checking the return
value of alloc_and_copy_ftrace_hash(). The subsequent call to
ftrace_match_records() may end up dereferencing the same. Add a check to
ensure this doesn't happen.
Link: http://lkml.kernel.org/r/26e92574f25ad23e7cafa3cf5f7a819de1832cbe.1562249521.git.naveen.n.rao@linux.vnet.ibm.com
Cc: stable@vger.kernel.org
Fixes: 1ec3a81a0cf42 ("ftrace: Have each function probe use its own ftrace_ops")
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 6200a6fe10e3..f9821a3374e9 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -4338,6 +4338,11 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,
old_hash = *orig_hash;
hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, old_hash);
+ if (!hash) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
ret = ftrace_match_records(hash, glob, strlen(glob));
/* Nothing found? */
--
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 ` [for-linus][PATCH 2/7] ftrace: Check for empty hash and comment the race with registering probes Steven Rostedt
2019-08-31 10:53 ` Steven Rostedt [this message]
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.217140090@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--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