Skip to content

Commit

Permalink
libbpf: Fix potential NULL dereference when parsing ELF
Browse files Browse the repository at this point in the history
Fix if condition filtering empty ELF sections to prevent NULL
dereference.

Fixes: 47ea741 ("libbpf: Skip empty sections in bpf_object__init_global_data_maps")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Hao Luo <haoluo@google.com>
Link: https://lore.kernel.org/bpf/20220816001929.369487-2-andrii@kernel.org
  • Loading branch information
Andrii Nakryiko authored and Daniel Borkmann committed Aug 17, 2022
1 parent 738a2f2 commit d4e6d68
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ static int bpf_object__init_global_data_maps(struct bpf_object *obj)
sec_desc = &obj->efile.secs[sec_idx];

/* Skip recognized sections with size 0. */
if (sec_desc->data && sec_desc->data->d_size == 0)
if (!sec_desc->data || sec_desc->data->d_size == 0)
continue;

switch (sec_desc->sec_type) {
Expand Down

0 comments on commit d4e6d68

Please sign in to comment.