From: Masami Hiramatsu <mhiramat@kernel.org>
To: rostedt@goodmis.org,
Francis Deslauriers <francis.deslauriers@efficios.com>,
peterz@infradead.org, Shuah Khan <shuah@kernel.org>
Cc: mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
linux-kernel@vger.kernel.org
Subject: [BUGFIX PATCH] tracing/kprobes: Fix within_notrace_func() to check only notrace functions
Date: Thu, 2 Aug 2018 16:50:48 +0900 [thread overview]
Message-ID: <153319624799.29007.13604430345640129926.stgit@devbox> (raw)
Fix within_notrace_func() to check only notrace functions
and to ignore the kprobe-event which can not solve symbol
address.
within_notrace_func() returns true if the given kprobe events
probe point seems like out-of-range. But that is not correct
place to check it, it should be done in kprobes afterwards.
kprobe-events allows user to define a probe point on "currently
unloaded module" so that it can trace the event while module
load. In this case, user will put a probe on a symbol which
is not in kallsyms yet and it hits the within_notrace_func().
In the result, kprobe-events always refuses if user defines
a probe on "currenly unloaded module".
Fixes: commit 45408c4f9250 ("tracing: kprobes: Prohibit probing on notrace function")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
kernel/trace/trace_kprobe.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index deeb03ae21e1..2e13f77b9a37 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -88,6 +88,7 @@ static nokprobe_inline unsigned long trace_kprobe_nhit(struct trace_kprobe *tk)
return nhit;
}
+/* Return 0 if it fails to find the symbol address */
static nokprobe_inline
unsigned long trace_kprobe_address(struct trace_kprobe *tk)
{
@@ -96,7 +97,8 @@ unsigned long trace_kprobe_address(struct trace_kprobe *tk)
if (tk->symbol) {
addr = (unsigned long)
kallsyms_lookup_name(trace_kprobe_symbol(tk));
- addr += tk->rp.kp.offset;
+ if (addr)
+ addr += tk->rp.kp.offset;
} else {
addr = (unsigned long)tk->rp.kp.addr;
}
@@ -519,8 +521,8 @@ static bool within_notrace_func(struct trace_kprobe *tk)
unsigned long offset, size, addr;
addr = trace_kprobe_address(tk);
- if (!kallsyms_lookup_size_offset(addr, &size, &offset))
- return true; /* Out of range. */
+ if (!addr || !kallsyms_lookup_size_offset(addr, &size, &offset))
+ return false;
return !ftrace_location_range(addr - offset, addr - offset + size);
}
reply other threads:[~2018-08-02 7:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=153319624799.29007.13604430345640129926.stgit@devbox \
--to=mhiramat@kernel.org \
--cc=francis.deslauriers@efficios.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=shuah@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
all inboxes | Powered by JetHome®