diff options
| author | Andrii Nakryiko <[email protected]> | 2022-08-16 00:19:26 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2022-08-17 20:42:10 +0000 |
| commit | d4e6d684f3bea46a2fc195765c77a3b26bcb080e (patch) | |
| tree | 91f8cd07ebb4fc28ca138dc381a61486ca1759f3 /tools/lib/bpf/libbpf.c | |
| parent | selftests/bpf: Tests libbpf autoattach APIs (diff) | |
| download | kernel-d4e6d684f3bea46a2fc195765c77a3b26bcb080e.tar.gz kernel-d4e6d684f3bea46a2fc195765c77a3b26bcb080e.zip | |
libbpf: Fix potential NULL dereference when parsing ELF
Fix if condition filtering empty ELF sections to prevent NULL
dereference.
Fixes: 47ea7417b074 ("libbpf: Skip empty sections in bpf_object__init_global_data_maps")
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Hao Luo <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 0159a43c7efd..146d35526b87 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -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) { |
