diff options
author | Masami Hiramatsu <mhiramat@kernel.org> | 2018-08-02 03:50:48 -0400 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2018-08-02 12:34:41 -0400 |
commit | 6bc6c77cfc6747292d5865d124cc31333b1b8536 (patch) | |
tree | d1099447d280fb8fa96019fc6dab2d23e904f424 | |
parent | 44ec3ec01fb7d54d1a14c138cb43b90a0e934b89 (diff) |
tracing/kprobes: Fix within_notrace_func() to check only notrace functions
Fix within_notrace_func() to check only notrace functions and to ignore the
kprobe-event which can not solve symbol addresses.
within_notrace_func() returns true if the given kprobe events probe point
seems to be out-of-range. But that is not the correct place to check for it,
it should be done in kprobes afterwards.
kprobe-events allow users to define a probe point on "currently unloaded
module" so that it can trace the event during module load. In this case, the
user will put a probe on a symbol which is not in kallsyms yet and it hits
the within_notrace_func(). As a result, kprobe-events always refuses if
user defines a probe on a "currenly unloaded module".
Fixes: commit 45408c4f9250 ("tracing: kprobes: Prohibit probing on notrace function")
Link: http://lkml.kernel.org/r/153319624799.29007.13604430345640129926.stgit@devbox
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | kernel/trace/trace_kprobe.c | 8 |
1 files 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) | |||
88 | return nhit; | 88 | return nhit; |
89 | } | 89 | } |
90 | 90 | ||
91 | /* Return 0 if it fails to find the symbol address */ | ||
91 | static nokprobe_inline | 92 | static nokprobe_inline |
92 | unsigned long trace_kprobe_address(struct trace_kprobe *tk) | 93 | unsigned long trace_kprobe_address(struct trace_kprobe *tk) |
93 | { | 94 | { |
@@ -96,7 +97,8 @@ unsigned long trace_kprobe_address(struct trace_kprobe *tk) | |||
96 | if (tk->symbol) { | 97 | if (tk->symbol) { |
97 | addr = (unsigned long) | 98 | addr = (unsigned long) |
98 | kallsyms_lookup_name(trace_kprobe_symbol(tk)); | 99 | kallsyms_lookup_name(trace_kprobe_symbol(tk)); |
99 | addr += tk->rp.kp.offset; | 100 | if (addr) |
101 | addr += tk->rp.kp.offset; | ||
100 | } else { | 102 | } else { |
101 | addr = (unsigned long)tk->rp.kp.addr; | 103 | addr = (unsigned long)tk->rp.kp.addr; |
102 | } | 104 | } |
@@ -519,8 +521,8 @@ static bool within_notrace_func(struct trace_kprobe *tk) | |||
519 | unsigned long offset, size, addr; | 521 | unsigned long offset, size, addr; |
520 | 522 | ||
521 | addr = trace_kprobe_address(tk); | 523 | addr = trace_kprobe_address(tk); |
522 | if (!kallsyms_lookup_size_offset(addr, &size, &offset)) | 524 | if (!addr || !kallsyms_lookup_size_offset(addr, &size, &offset)) |
523 | return true; /* Out of range. */ | 525 | return false; |
524 | 526 | ||
525 | return !ftrace_location_range(addr - offset, addr - offset + size); | 527 | return !ftrace_location_range(addr - offset, addr - offset + size); |
526 | } | 528 | } |