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  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]
Date:   Thu, 10 Dec 2020 12:34:08 +0800
From:   Zhu Yanjun <zyjzyj2000@...il.com>
To:     Toke Høiland-Jørgensen <toke@...hat.com>
Cc:     Daniel Borkmann <daniel@...earbox.net>,
        Zhu Yanjun <yanjun.zhu@...el.com>,
        Björn Töpel <bjorn.topel@...el.com>,
        "Karlsson, Magnus" <magnus.karlsson@...el.com>,
        netdev <netdev@...r.kernel.org>, jonathan.lemon@...il.com
Subject: Re: [PATCH v2 1/1] xdp: avoid calling kfree twice

On Wed, Dec 9, 2020 at 6:44 PM Toke Høiland-Jørgensen <toke@...hat.com> wrote:
>
> Zhu Yanjun <zyjzyj2000@...il.com> writes:
>
> > On Wed, Dec 9, 2020 at 1:12 AM Daniel Borkmann <daniel@...earbox.net> wrote:
> >>
> >> On 12/9/20 6:03 AM, Zhu Yanjun wrote:
> >> > In the function xdp_umem_pin_pages, if npgs != umem->npgs and
> >> > npgs >= 0, the function xdp_umem_unpin_pages is called. In this
> >> > function, kfree is called to handle umem->pgs, and then in the
> >> > function xdp_umem_pin_pages, kfree is called again to handle
> >> > umem->pgs. Eventually, umem->pgs is freed twice.
> >> >
> >> > Acked-by: Björn Töpel <bjorn.topel@...el.com>
> >> > Signed-off-by: Zhu Yanjun <yanjun.zhu@...el.com>
> >>
> >> Please also fix up the commit log according to Bjorn's prior feedback [0].
> >> If it's just a cleanup, it should state so, the commit message right now
> >> makes it sound like an actual double free bug.
> >
> > The umem->pgs is actually freed twice. Since umem->pgs is set to NULL
> > after the first kfree,
> > the second kfree would not trigger call trace.
> > IMO, the commit log is very clear about this.
>
> Yes, it is very clear; and also wrong. As someone already pointed out,
> passing a NULL pointer to kfree() doesn't actually lead to a double
> free:

In your commit, does "double free" mean the call trace bug? If so, I
will correct it in my commit log.
In my commit log, I just mean that kfree is called twice. And the
second kfree is meaningless. And since NULL
is passed to it, this will not trigger "double free" CallTrace.

I will send the latest version soon.

Zhu Yanjun
>
> https://elixir.bootlin.com/linux/latest/source/mm/slub.c#L4106
>
> -Toke
>

Powered by blists - more mailing lists