[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-6143c6fb1e8f9bde9c434038f7548a19d36b55e7@git.kernel.org>
Date: Wed, 13 Feb 2019 01:01:24 -0800
From: tip-bot for Masami Hiramatsu <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: mathieu.desnoyers@...icios.com, mhiramat@...nel.org,
tglx@...utronix.de, linux-kernel@...r.kernel.org, acme@...hat.com,
righi.andrea@...il.com, torvalds@...ux-foundation.org,
peterz@...radead.org, rostedt@...dmis.org, mingo@...nel.org,
hpa@...or.com, jolsa@...hat.com, alexander.shishkin@...ux.intel.com
Subject: [tip:perf/core] kprobes: Search non-suffixed symbol in blacklist
Commit-ID: 6143c6fb1e8f9bde9c434038f7548a19d36b55e7
Gitweb: https://git.kernel.org/tip/6143c6fb1e8f9bde9c434038f7548a19d36b55e7
Author: Masami Hiramatsu <mhiramat@...nel.org>
AuthorDate: Wed, 13 Feb 2019 01:13:12 +0900
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Wed, 13 Feb 2019 08:16:40 +0100
kprobes: Search non-suffixed symbol in blacklist
Newer GCC versions can generate some different instances of a function
with suffixed symbols if the function is optimized and only
has a part of that. (e.g. .constprop, .part etc.)
In this case, it is not enough to check the entry of kprobe
blacklist because it only records non-suffixed symbol address.
To fix this issue, search non-suffixed symbol in blacklist if
given address is within a symbol which has a suffix.
Note that this can cause false positive cases if a kprobe-safe
function is optimized to suffixed instance and has same name
symbol which is blacklisted.
But I would like to chose a fail-safe design for this issue.
Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
Reviewed-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Andrea Righi <righi.andrea@...il.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Link: http://lkml.kernel.org/r/154998799234.31052.6136378903570418008.stgit@devbox
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/kprobes.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index f4ddfdd2d07e..c83e54727131 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1396,7 +1396,7 @@ bool __weak arch_within_kprobe_blacklist(unsigned long addr)
addr < (unsigned long)__kprobes_text_end;
}
-bool within_kprobe_blacklist(unsigned long addr)
+static bool __within_kprobe_blacklist(unsigned long addr)
{
struct kprobe_blacklist_entry *ent;
@@ -1410,7 +1410,26 @@ bool within_kprobe_blacklist(unsigned long addr)
if (addr >= ent->start_addr && addr < ent->end_addr)
return true;
}
+ return false;
+}
+bool within_kprobe_blacklist(unsigned long addr)
+{
+ char symname[KSYM_NAME_LEN], *p;
+
+ if (__within_kprobe_blacklist(addr))
+ return true;
+
+ /* Check if the address is on a suffixed-symbol */
+ if (!lookup_symbol_name(addr, symname)) {
+ p = strchr(symname, '.');
+ if (!p)
+ return false;
+ *p = '\0';
+ addr = (unsigned long)kprobe_lookup_name(symname, 0);
+ if (addr)
+ return __within_kprobe_blacklist(addr);
+ }
return false;
}
Powered by blists - more mailing lists