Skip to content

Commit

Permalink
selftests/bpf: ksym_search won't check symbols exists
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel T. Lee authored and Daniel Borkmann committed Apr 4, 2019
1 parent cc441a6 commit 0979ff7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/testing/selftests/bpf/trace_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0979ff7

Please sign in to comment.