提交 faf399eb 编写于 作者: I Ian Rogers 提交者: Zheng Zengkai

libbpf: Add NULL check to add_dummy_ksym_var

mainline inclusion
from mainline-5.13-rc4
commit 9683e577
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9683e5775c75097c46bd24e65411b16ac6c6cbb3

-------------------------------------------------

Avoids a segv if btf isn't present. Seen on the call path
__bpf_object__open calling bpf_object__collect_externs.

Fixes: 5bd022ec (libbpf: Support extern kernel function)
Suggested-by: NStanislav Fomichev <sdf@google.com>
Suggested-by: NPetar Penkov <ppenkov@google.com>
Signed-off-by: NIan Rogers <irogers@google.com>
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210504234910.976501-1-irogers@google.com
(cherry picked from commit 9683e577)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 e67bce2b
......@@ -3217,6 +3217,9 @@ static int add_dummy_ksym_var(struct btf *btf)
const struct btf_var_secinfo *vs;
const struct btf_type *sec;
if (!btf)
return 0;
sec_btf_id = btf__find_by_name_kind(btf, KSYMS_SEC,
BTF_KIND_DATASEC);
if (sec_btf_id < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册