summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDaniel T. Lee <danieltimlee@gmail.com>2019-04-04 07:17:55 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-31 06:46:25 -0700
commitf8f54929bd239bd875c1004c997b1ffc450a45f4 (patch)
tree1a59f31132b39c0a717abe1c030767719e8392be /tools
parentef8e5a78406d103ac546a7a50cb02f05fec7987f (diff)
downloadlinux-stable-f8f54929bd239bd875c1004c997b1ffc450a45f4.tar.gz
linux-stable-f8f54929bd239bd875c1004c997b1ffc450a45f4.tar.bz2
linux-stable-f8f54929bd239bd875c1004c997b1ffc450a45f4.zip
selftests/bpf: ksym_search won't check symbols exists
[ Upstream commit 0979ff7992fb6f4eb837995b12f4071dcafebd2d ] Currently, ksym_search located at trace_helpers won't check symbols are existing or not. In ksym_search, when symbol is not found, it will return &syms[0](_stext). But when the kernel symbols are not loaded, it will return NULL, which is not a desired action. This commit will add verification logic whether symbols are loaded prior to the symbol search. Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/trace_helpers.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c
index cabe2a3a3b30..cf156b353679 100644
--- a/tools/testing/selftests/bpf/trace_helpers.c
+++ b/tools/testing/selftests/bpf/trace_helpers.c
@@ -51,6 +51,10 @@ struct ksym *ksym_search(long key)
int start = 0, end = sym_cnt;
int result;
+ /* kallsyms not loaded. return NULL */
+ if (sym_cnt <= 0)
+ return NULL;
+
while (start < end) {
size_t mid = start + (end - start) / 2;