diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2022-03-20 17:30:03 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-03-21 05:21:38 +0300 |
commit | 7ada3787e91c89b0aa7abf47682e8e587b855c13 (patch) | |
tree | e85380b9690ec176cbff5a327a1156424250ee71 /net | |
parent | e1cc1f39981b06ba22a0c92e800e9fd8ba59d2d3 (diff) | |
download | linux-7ada3787e91c89b0aa7abf47682e8e587b855c13.tar.xz |
bpf: Check for NULL return from bpf_get_btf_vmlinux
When CONFIG_DEBUG_INFO_BTF is disabled, bpf_get_btf_vmlinux can return a
NULL pointer. Check for it in btf_get_module_btf to prevent a NULL pointer
dereference.
While kernel test robot only complained about this specific case, let's
also check for NULL in other call sites of bpf_get_btf_vmlinux.
Fixes: 9492450fd287 ("bpf: Always raise reference in btf_get_module_btf")
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220320143003.589540-1-memxor@gmail.com
Diffstat (limited to 'net')
-rw-r--r-- | net/core/bpf_sk_storage.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c index 7aff1206a851..e3ac36380520 100644 --- a/net/core/bpf_sk_storage.c +++ b/net/core/bpf_sk_storage.c @@ -406,6 +406,8 @@ static bool bpf_sk_storage_tracing_allowed(const struct bpf_prog *prog) case BPF_TRACE_FENTRY: case BPF_TRACE_FEXIT: btf_vmlinux = bpf_get_btf_vmlinux(); + if (IS_ERR_OR_NULL(btf_vmlinux)) + return false; btf_id = prog->aux->attach_btf_id; t = btf_type_by_id(btf_vmlinux, btf_id); tname = btf_name_by_offset(btf_vmlinux, t->name_off); |