Re: [PATCH bpf-next 1/4] libbpf: fix potential NULL dereference when parsing ELF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 15, 2022 at 8:52 PM Andrii Nakryiko <andrii@xxxxxxxxxx> wrote:
>
> 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 <andrii@xxxxxxxxxx>

Acked-by: Hao Luo <haoluo@xxxxxxxxxx>

> ---
>  tools/lib/bpf/libbpf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index aa05a99b913d..5f0281e61437 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -1646,7 +1646,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) {
> --
> 2.30.2
>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux