lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2c29b3cd-ec23-f9c8-ae9f-d713ce3dd4f0@meizu.com>
Date:   Fri, 8 Apr 2022 09:30:07 +0800
From:   baihaowen <baihaowen@...zu.com>
To:     Andrii Nakryiko <andrii.nakryiko@...il.com>
CC:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] libbpf: potential NULL dereference in
 usdt_manager_attach_usdt()

在 4/8/22 3:04 AM, Andrii Nakryiko 写道:
> On Wed, Apr 6, 2022 at 7:38 PM Haowen Bai <baihaowen@...zu.com> wrote:
>> link could be null but still dereference bpf_link__destroy(&link->link)
>> and it will lead to a null pointer access.
>>
>> Signed-off-by: Haowen Bai <baihaowen@...zu.com>
>> ---
>>  tools/lib/bpf/usdt.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/lib/bpf/usdt.c b/tools/lib/bpf/usdt.c
>> index 1bce2eab5e89..b02ebc4ba57c 100644
>> --- a/tools/lib/bpf/usdt.c
>> +++ b/tools/lib/bpf/usdt.c
>> @@ -996,7 +996,7 @@ struct bpf_link *usdt_manager_attach_usdt(struct usdt_manager *man, const struct
>>         link = calloc(1, sizeof(*link));
>>         if (!link) {
>>                 err = -ENOMEM;
>> -               goto err_out;
>> +               goto link_err;
> this is not a complete fix because there are two more similar goto
> err_out; above which you didn't fix. I think better fix is to just add
> if (link) check before bpf_link__destroy(), which is what I did
> locally when applying.
>
>
>>         }
>>
>>         link->usdt_man = man;
>> @@ -1072,7 +1072,7 @@ struct bpf_link *usdt_manager_attach_usdt(struct usdt_manager *man, const struct
>>
>>  err_out:
>>         bpf_link__destroy(&link->link);
>> -
>> +link_err:
>>         free(targets);
>>         hashmap__free(specs_hash);
>>         if (elf)
>> --
>> 2.7.4
>>
Thank you for your kindness help. :)

-- 
Haowen Bai

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ