]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Check for NULL return from bpf_get_btf_vmlinux
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Sun, 20 Mar 2022 14:30:03 +0000 (20:00 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 21 Mar 2022 02:21:38 +0000 (19:21 -0700)
commitcfdda9faaf4964b63dbbb85f1f93d04a4e7e101a
treee85380b9690ec176cbff5a327a1156424250ee71
parent7092421680b234f0950a64334c58e2f6c9d01832
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: 7385d6b884b3 ("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
kernel/bpf/btf.c
net/core/bpf_sk_storage.c