linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dongliang Mu <mudongliangabcd@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Steffen Klassert <steffen.klassert@secunet.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	syzbot+b9cfd1cc5d57ee0a09ab@syzkaller.appspotmail.com,
	stable@vger.kernel.org,
	"open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: xfrm: fix bug in ipcomp_free_scratches
Date: Mon, 16 Aug 2021 19:36:07 +0800	[thread overview]
Message-ID: <CAD-N9QWwmRuPOKZ2BX8ACde4K2GNFUsAWzcciKVG9BwLPcM2-A@mail.gmail.com> (raw)
In-Reply-To: <20210816075346.GA10906@gondor.apana.org.au>

On Mon, Aug 16, 2021 at 3:53 PM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Mon, Aug 16, 2021 at 03:38:29PM +0800, Dongliang Mu wrote:
> >
> > -     for_each_possible_cpu(i)
> > -             vfree(*per_cpu_ptr(scratches, i));
> > +     for_each_possible_cpu(i) {
> > +             void *scratch = *per_cpu_ptr(scratches, i);
> > +             if (!scratch)
> > +                     vfree(scratch);
> > +     }
>
> This patch is unnecessary.  Please check the implementation of
> vfree, it already checks for NULL pointers just like most of our
> free primitives.

Hi Herbert,

since there is no reproducer in the syzbot, I guess the problem might be:

if vmalloc_node in the ipcomp_alloc_scratches returns a NULL pointer,
it directly returns NULL without updating the per_cpu_ptr(scratches,
i).

Therefore, in the ipcomp_free_scratches, vfree will take an invalid
and outdated per_cpu_ptr as its argument, leading to the bug - BUG:
unable to handle kernel paging request in ipcomp_free_scratches.

Any idea?

>
> Cheers,
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      parent reply	other threads:[~2021-08-16 11:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16  7:38 [PATCH] net: xfrm: fix bug in ipcomp_free_scratches Dongliang Mu
2021-08-16  7:53 ` Herbert Xu
2021-08-16  9:35   ` Dongliang Mu
2021-08-16 11:36   ` Dongliang Mu [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-N9QWwmRuPOKZ2BX8ACde4K2GNFUsAWzcciKVG9BwLPcM2-A@mail.gmail.com \
    --to=mudongliangabcd@gmail.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=syzbot+b9cfd1cc5d57ee0a09ab@syzkaller.appspotmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).