All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhu Yanjun <zyjzyj2000@gmail.com>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: "Daniel Borkmann" <daniel@iogearbox.net>,
	"Zhu Yanjun" <yanjun.zhu@intel.com>,
	"Björn Töpel" <bjorn.topel@intel.com>,
	"Karlsson, Magnus" <magnus.karlsson@intel.com>,
	netdev <netdev@vger.kernel.org>,
	jonathan.lemon@gmail.com
Subject: Re: [PATCH v2 1/1] xdp: avoid calling kfree twice
Date: Thu, 10 Dec 2020 12:34:08 +0800	[thread overview]
Message-ID: <CAD=hENc-VK2fKeQ108nYSDZ3B0s-tDBXLoc--bfSMndsOqEUqw@mail.gmail.com> (raw)
In-Reply-To: <87a6unp8ck.fsf@toke.dk>

On Wed, Dec 9, 2020 at 6:44 PM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> Zhu Yanjun <zyjzyj2000@gmail.com> writes:
>
> > On Wed, Dec 9, 2020 at 1:12 AM Daniel Borkmann <daniel@iogearbox.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@intel.com>
> >> > Signed-off-by: Zhu Yanjun <yanjun.zhu@intel.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
>

      reply	other threads:[~2020-12-10  4:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09  5:03 [PATCH v2 1/1] xdp: avoid calling kfree twice Zhu Yanjun
2020-12-08 17:12 ` Daniel Borkmann
2020-12-09  4:30   ` Zhu Yanjun
2020-12-09 10:44     ` Toke Høiland-Jørgensen
2020-12-10  4:34       ` Zhu Yanjun [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAD=hENc-VK2fKeQ108nYSDZ3B0s-tDBXLoc--bfSMndsOqEUqw@mail.gmail.com' \
    --to=zyjzyj2000@gmail.com \
    --cc=bjorn.topel@intel.com \
    --cc=daniel@iogearbox.net \
    --cc=jonathan.lemon@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    --cc=yanjun.zhu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.