netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kadlecsik József" <kadlec@blackhole.kfki.hu>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: syzbot <syzbot+4c3cc6dbe7259dbf9054@syzkaller.appspotmail.com>,
	Arvid Brodin <arvid.brodin@alten.se>,
	coreteam@netfilter.org, David Miller <davem@davemloft.net>,
	florent.fourcot@wifirst.fr, Florian Westphal <fw@strlen.de>,
	jeremy@azazel.net, Johannes Berg <johannes.berg@intel.com>,
	kadlec@netfilter.org, LKML <linux-kernel@vger.kernel.org>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	NetFilter <netfilter-devel@vger.kernel.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Subject: Re: KASAN: use-after-free Read in bitmap_port_ext_cleanup
Date: Fri, 10 Jan 2020 20:13:56 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.2001102012430.21802@blackhole.kfki.hu> (raw)
In-Reply-To: <CAM_iQpWz+ivP2vS50rY94DiR6qSh1W0WKjqgBNKYpUH_VFPgGw@mail.gmail.com>

Hi,

On Fri, 10 Jan 2020, Cong Wang wrote:

> On Fri, Jan 10, 2020 at 10:44 AM syzbot
> <syzbot+4c3cc6dbe7259dbf9054@syzkaller.appspotmail.com> wrote:
> >
> > syzbot found the following crash on:
> >
> > HEAD commit:    b07f636f Merge tag 'tpmdd-next-20200108' of git://git.infr..
> > git tree:       upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=16c03259e00000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=18698c0c240ba616
> > dashboard link: https://syzkaller.appspot.com/bug?extid=4c3cc6dbe7259dbf9054
> > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > userspace arch: i386
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=10c365c6e00000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=117df9e1e00000
> >
> > The bug was bisected to:
> >
> > commit b9a1e627405d68d475a3c1f35e685ccfb5bbe668
> > Author: Cong Wang <xiyou.wangcong@gmail.com>
> > Date:   Thu Jul 4 00:21:13 2019 +0000
> >
> >      hsr: implement dellink to clean up resources
> >
> > bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=118759e1e00000
> > final crash:    https://syzkaller.appspot.com/x/report.txt?x=138759e1e00000
> > console output: https://syzkaller.appspot.com/x/log.txt?x=158759e1e00000
> >
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+4c3cc6dbe7259dbf9054@syzkaller.appspotmail.com
> > Fixes: b9a1e627405d ("hsr: implement dellink to clean up resources")
> >
> > ==================================================================
> > BUG: KASAN: use-after-free in test_bit
> > include/asm-generic/bitops/instrumented-non-atomic.h:110 [inline]
> > BUG: KASAN: use-after-free in bitmap_port_ext_cleanup+0xe6/0x2a0
> > net/netfilter/ipset/ip_set_bitmap_gen.h:51
> > Read of size 8 at addr ffff8880a87a47c0 by task syz-executor559/9563
> >
> > CPU: 0 PID: 9563 Comm: syz-executor559 Not tainted 5.5.0-rc5-syzkaller #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > Google 01/01/2011
> > Call Trace:
> >   __dump_stack lib/dump_stack.c:77 [inline]
> >   dump_stack+0x197/0x210 lib/dump_stack.c:118
> >   print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
> >   __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
> >   kasan_report+0x12/0x20 mm/kasan/common.c:639
> >   check_memory_region_inline mm/kasan/generic.c:185 [inline]
> >   check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192
> >   __kasan_check_read+0x11/0x20 mm/kasan/common.c:95
> >   test_bit include/asm-generic/bitops/instrumented-non-atomic.h:110 [inline]
> >   bitmap_port_ext_cleanup+0xe6/0x2a0
> 
> map->members is freed by ip_set_free() right before using it in
> mtype_ext_cleanup() again. So I think probably we just have to
> move it down:

Yes, exactly. As you suggested, could you submit a patch?

Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>

Best regards,
Jozsef
 
> diff --git a/net/netfilter/ipset/ip_set_bitmap_gen.h
> b/net/netfilter/ipset/ip_set_bitmap_gen.h
> index 1abd6f0dc227..077a2cb65fcb 100644
> --- a/net/netfilter/ipset/ip_set_bitmap_gen.h
> +++ b/net/netfilter/ipset/ip_set_bitmap_gen.h
> @@ -60,9 +60,9 @@ mtype_destroy(struct ip_set *set)
>         if (SET_WITH_TIMEOUT(set))
>                 del_timer_sync(&map->gc);
> 
> -       ip_set_free(map->members);
>         if (set->dsize && set->extensions & IPSET_EXT_DESTROY)
>                 mtype_ext_cleanup(set);
> +       ip_set_free(map->members);
>         ip_set_free(map);
> 
>         set->data = NULL;
> 
> Thanks.
> 

-
E-mail  : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics
          H-1525 Budapest 114, POB. 49, Hungary

      reply	other threads:[~2020-01-10 19:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 18:44 KASAN: use-after-free Read in bitmap_port_ext_cleanup syzbot
2020-01-10 19:09 ` Cong Wang
2020-01-10 19:13   ` Kadlecsik József [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=alpine.DEB.2.20.2001102012430.21802@blackhole.kfki.hu \
    --to=kadlec@blackhole.kfki.hu \
    --cc=arvid.brodin@alten.se \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=florent.fourcot@wifirst.fr \
    --cc=fw@strlen.de \
    --cc=jeremy@azazel.net \
    --cc=johannes.berg@intel.com \
    --cc=kadlec@netfilter.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=syzbot+4c3cc6dbe7259dbf9054@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=xiyou.wangcong@gmail.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).