Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1062005ybl; Fri, 10 Jan 2020 11:23:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzImdtHa3eGQd2CAJ8SRAnn06nl5djzbPojJ+8FzCKtWHAmJEPDioSw0eiz0Bqf8eztDH+K X-Received: by 2002:a05:6808:143:: with SMTP id h3mr3526901oie.61.1578684190113; Fri, 10 Jan 2020 11:23:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578684190; cv=none; d=google.com; s=arc-20160816; b=MoUWtDqAF1mcH64uTbxylVdHjDYvHYW+6bVo+JJjaUedwHDL1zDF0GdWF1DYCGclqH blIleDf6fHD0mV8lWPQFZ9sSf2di3CJ3DbkUfl4wxRPsL+9lSDiOT7vS5Gc0a2TNfeBo YrXNbGMrKZh2G+ibT5H/CRHxP4Fth2Jyf1xz1qFB79IIHrhhuqgBOV5AjIHEJKjkaynf FHNzEKiMDSKOpDb7Crxr3Ik+aaev94Blvj4GGuhvgL85Vfi+rKGmvZiMKhir/apzSXuq lQjRJa4DyaIEaYXn6XWrayw71D4Yze847qUrwLtMTrVGmuGmBlvgoxtYf3AjDxQpHEho EBfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=mhfd0WLRJBSwVW5UKYt7ItvCkPprQpYFWOpPlBXdZyM=; b=nLhNqxOZrVKR6Zd9FpY+ql2laHjByizT7rHZaPeCjt0ZXk1TkXQOT1apvr5iT0eNd0 4/m8d776HhIbCx8Y7owSqzlwgeDkmGZnKRhV6QQZaQKIAsXl9+AskGWkkBrdtC401Z7p zGSiU+6c7t3BBA65P6EsyBY5pBvpG3wb/USMXSKfxDIzlZjfCEWn24NJ7CB5YPzukVqM q9JAMilMv4h9GHFkKtYhjA5DVo/j/hRR4PD/ccJRyf+Q0KoYqFh6v3YA3y7XP9sVIG1X mQlZ8PSd5yEtZIA08ty2ij8PzBsd4mHAnE7Myi5AumMcv4vABgpy9f4CDACVCwZyBrLY WceQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@blackhole.kfki.hu header.s=20151130 header.b=NDeLR+Ik; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=blackhole.kfki.hu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8si2023745otc.118.2020.01.10.11.22.57; Fri, 10 Jan 2020 11:23:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@blackhole.kfki.hu header.s=20151130 header.b=NDeLR+Ik; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=blackhole.kfki.hu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728369AbgAJTVg (ORCPT + 99 others); Fri, 10 Jan 2020 14:21:36 -0500 Received: from smtp-out.kfki.hu ([148.6.0.45]:48909 "EHLO smtp-out.kfki.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728130AbgAJTVg (ORCPT ); Fri, 10 Jan 2020 14:21:36 -0500 X-Greylist: delayed 453 seconds by postgrey-1.27 at vger.kernel.org; Fri, 10 Jan 2020 14:21:34 EST Received: from localhost (localhost [127.0.0.1]) by smtp0.kfki.hu (Postfix) with ESMTP id 35C14674013E; Fri, 10 Jan 2020 20:14:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= blackhole.kfki.hu; h=mime-version:user-agent:references :message-id:in-reply-to:from:from:date:date:received:received :received; s=20151130; t=1578683637; x=1580498038; bh=mhfd0WLRJB SwVW5UKYt7ItvCkPprQpYFWOpPlBXdZyM=; b=NDeLR+IkKvbkt+SVVpA0MLUJC1 YVUylOHUmZZ1k8cYZBWUyiPk/JK7Jy8Og0upsq6OOvoPDgk30QporcHPr/cK1qkQ ZNur9TXsrMPo+KUMM3A0/RpVThsp5q8qQl2Q3I22CsLYVKh++qwlejs7fTNXImFn KkQK0wG4R7Of3TjCk= X-Virus-Scanned: Debian amavisd-new at smtp0.kfki.hu Received: from smtp0.kfki.hu ([127.0.0.1]) by localhost (smtp0.kfki.hu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP; Fri, 10 Jan 2020 20:13:57 +0100 (CET) Received: from blackhole.kfki.hu (blackhole.kfki.hu [IPv6:2001:738:5001:1::240:2]) by smtp0.kfki.hu (Postfix) with ESMTP id 7CBCE674013D; Fri, 10 Jan 2020 20:13:56 +0100 (CET) Received: by blackhole.kfki.hu (Postfix, from userid 1000) id 2414B2140B; Fri, 10 Jan 2020 20:13:56 +0100 (CET) Date: Fri, 10 Jan 2020 20:13:56 +0100 (CET) From: =?UTF-8?Q?Kadlecsik_J=C3=B3zsef?= To: Cong Wang cc: syzbot , Arvid Brodin , coreteam@netfilter.org, David Miller , florent.fourcot@wifirst.fr, Florian Westphal , jeremy@azazel.net, Johannes Berg , kadlec@netfilter.org, LKML , Linux Kernel Network Developers , NetFilter , Pablo Neira Ayuso , syzkaller-bugs Subject: Re: KASAN: use-after-free Read in bitmap_port_ext_cleanup In-Reply-To: Message-ID: References: <000000000000f744e0059bcd8216@google.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, 10 Jan 2020, Cong Wang wrote: > On Fri, Jan 10, 2020 at 10:44 AM syzbot > 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 > > 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 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