aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorDaniel T. Lee <danieltimlee@gmail.com>2019-04-04 07:17:55 +0900
committerDaniel Borkmann <daniel@iogearbox.net>2019-04-04 16:43:46 +0200
commit0979ff7992fb6f4eb837995b12f4071dcafebd2d (patch)
tree82e7bbd768ae68415384cf0d39384857157e29e2 /tools/testing/selftests
parentMerge branch 'bpf-verifier-scalability' (diff)
downloadlinux-dev-0979ff7992fb6f4eb837995b12f4071dcafebd2d.tar.xz
linux-dev-0979ff7992fb6f4eb837995b12f4071dcafebd2d.zip
selftests/bpf: ksym_search won't check symbols exists
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>
Diffstat (limited to 'tools/testing/selftests')
-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 4cdb63bf0521..9a9fc6c9b70b 100644
--- a/tools/testing/selftests/bpf/trace_helpers.c
+++ b/tools/testing/selftests/bpf/trace_helpers.c
@@ -52,6 +52,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;