Commit f382ab1a authored by Daniel T. Lee's avatar Daniel T. Lee Committed by Greg Kroah-Hartman

selftests/bpf: ksym_search won't check symbols exists

[ Upstream commit 0979ff79 ]

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: default avatarDaniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 3f52cbfe
...@@ -52,6 +52,10 @@ struct ksym *ksym_search(long key) ...@@ -52,6 +52,10 @@ struct ksym *ksym_search(long key)
int start = 0, end = sym_cnt; int start = 0, end = sym_cnt;
int result; int result;
/* kallsyms not loaded. return NULL */
if (sym_cnt <= 0)
return NULL;
while (start < end) { while (start < end) {
size_t mid = start + (end - start) / 2; size_t mid = start + (end - start) / 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment