diff options
author | 2022-10-12 10:23:53 +0800 | |
---|---|---|
committer | 2022-10-13 10:53:34 -0700 | |
commit | d0d382f95a9270dcf803539d6781d6bd67e3f5b2 (patch) | |
tree | f42662b1b505ba76f5f4e635ebd6d003295c8342 /kernel | |
parent | libbpf: Deal with section with no data gracefully (diff) | |
download | wireguard-linux-d0d382f95a9270dcf803539d6781d6bd67e3f5b2.tar.xz wireguard-linux-d0d382f95a9270dcf803539d6781d6bd67e3f5b2.zip |
libbpf: Fix null-pointer dereference in find_prog_by_sec_insn()
When there are no program sections, obj->programs is left unallocated,
and find_prog_by_sec_insn()'s search lands on &obj->programs[0] == NULL,
and will cause null-pointer dereference in the following access to
prog->sec_idx.
Guard the search with obj->nr_programs similar to what's being done in
__bpf_program__iter() to prevent null-pointer access from happening.
Fixes: db2b8b06423c ("libbpf: Support CO-RE relocations for multi-prog sections")
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221012022353.7350-4-shung-hsi.yu@suse.com
Diffstat (limited to 'kernel')
0 files changed, 0 insertions, 0 deletions