Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2337562ybz; Thu, 23 Apr 2020 16:17:07 -0700 (PDT) X-Google-Smtp-Source: APiQypJuCX2MSazXf22prJ27FDmZ1wa6GU0q0SLvZ0tfmJidlKVvXEJP76IGAXlB/U1eyC0wex/0 X-Received: by 2002:a05:6402:1422:: with SMTP id c2mr5033420edx.179.1587683826985; Thu, 23 Apr 2020 16:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587683826; cv=none; d=google.com; s=arc-20160816; b=1IVLMldvek8FgpF8NWGzCBvkRmgmSusKcmu/RiYzFwJRqn0bfBHOAYHG9sG014oZki 0Jp5mGoLUp6wf/qVP+fFHdQPDEspT68gZ1r4roDWmabkyoYSVfbKZUNPFhWZcSbd9TYh 0vTKSzfOEZtTO0kdwn9z330LaHx1DbjZUtsv0Rwkq2hVFmNpXdqyS2VZk4UjU9mSKY4e J4SwiOzyVP8r5kEx7sr0eNeNDr5ExL43F6fpInD8Jwal5kO6qHSP3SXIUd/6UuCUx7P8 5Q5U+TccYCoPpxbaulYdQ2XlpXIcxreo7SIT8HKxJXyMsPOXVDZgXvgq2WM+JTeS9WQ8 jzSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=2K8MEcoRaZNV+MK7hPEO0HfExei/OSroWD2xz6ARF0k=; b=UyJRr+NE0s+83qdgV+nGp70R1nMONpOfp9wwqjpy6Pd4gAFWtqn4EIo/uSJmLsLiqv Jj2RdImw4FtR8Yo/MvVBi3Ep8h/uc7vXz1Ll5MeOzMUZAcHYa5l1znStbHOBDm1+LKlR QsyiGBO1gjpPOmjfimQ2v++0MxgtBSxFbHV8E9Go8QnIEW90uwSAxuI/7cHWPc6EqcEP EefWKJPFXmCMdDudwfprD0lOdp/zHEAWYvpVPvIa2X8mXYjhFH79wzDuoBmN1WGHK3bU R7+ozatPGMtych6F4kc8nnVzeZ5pgpV1FKcLc8Frrq9Ebk7etnxhH7MYw6mqEyjUOJSZ 5a+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 30si2166363edr.255.2020.04.23.16.16.43; Thu, 23 Apr 2020 16:17:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729299AbgDWXMO (ORCPT + 99 others); Thu, 23 Apr 2020 19:12:14 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50124 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728521AbgDWXGv (ORCPT ); Thu, 23 Apr 2020 19:06:51 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvZ-0004na-M3; Fri, 24 Apr 2020 00:06:41 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvV-00E6w8-T7; Fri, 24 Apr 2020 00:06:37 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Pablo Neira Ayuso" , syzbot+4c3cc6dbe7259dbf9054@syzkaller.appspotmail.com, "Jozsef Kadlecsik" , "Cong Wang" Date: Fri, 24 Apr 2020 00:06:45 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 178/245] netfilter: fix a use-after-free in mtype_destroy() In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang commit c120959387efa51479056fd01dc90adfba7a590c upstream. map->members is freed by ip_set_free() right before using it in mtype_ext_cleanup() again. So we just have to move it down. Reported-by: syzbot+4c3cc6dbe7259dbf9054@syzkaller.appspotmail.com Fixes: 40cd63bf33b2 ("netfilter: ipset: Support extensions which need a per data destroy function") Acked-by: Jozsef Kadlecsik Signed-off-by: Cong Wang Signed-off-by: Pablo Neira Ayuso [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- net/netfilter/ipset/ip_set_bitmap_gen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/netfilter/ipset/ip_set_bitmap_gen.h +++ b/net/netfilter/ipset/ip_set_bitmap_gen.h @@ -66,12 +66,12 @@ mtype_destroy(struct ip_set *set) if (SET_WITH_TIMEOUT(set)) del_timer_sync(&map->gc); - ip_set_free(map->members); if (set->dsize) { if (set->extensions & IPSET_EXT_DESTROY) mtype_ext_cleanup(set); ip_set_free(map->extensions); } + ip_set_free(map->members); kfree(map); set->data = NULL;