Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4822967ybl; Wed, 22 Jan 2020 05:25:18 -0800 (PST) X-Google-Smtp-Source: APXvYqy7F9qflPmPU6ayOztxZQ8NI3u4RrPUDpFPUlZFEtT/AGE4Cxo2L6pruyKwuDxRtxth4dZ1 X-Received: by 2002:aca:48cd:: with SMTP id v196mr6979683oia.102.1579699518438; Wed, 22 Jan 2020 05:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699518; cv=none; d=google.com; s=arc-20160816; b=1Lj6TNug+CefSRb9Xx+NsriEntvbbQEYZ7bxxc0CSjKpGcV0Qu9Cu5Zt9YMvKdViU4 DX8aUqJdP12srtz+GXShMDuFyudKEfz6nLjbRpNhiI3I/lHU9UjRGaH5wL0vYPg5xaz3 O9GdFAPtQOQXfb2WV4vtnrIl9ErJlTKcerQdH1BxVMrP2Pz2Ot/oBm7lQAFwpdwoVJRg HMTr4PQisXT5H/RKCMkjhffN1MF/3nAF4vOmS36H/lQ0OufdGph7P4iI8wCsun2Fq8ta qBJUTldsww0+5f2qvUQueUG9D3Lg1BRDejEnwXkcX0ib81HoCG44Spym4eOKvDuKnopg jWhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8o3h3jtt9latzQ2ZeksaUpDjueTB0fiS42cuaVheIxQ=; b=bZh6BkRfXA941q9xPP9TWLHO2/tIi+CpKAXTjrPPERGPwLrCbX2nS3zAEaK7GAnWEF ke/g8Kl9WxxJ/if2k9BVrttkRt3OlgIRHLVkmOtMBEZYpBDJ96QfmgzNLin6gwPOo+TM HOBt/ohf0xdyh10T2DhcmBIyHNh4bZUgjsY9pqiUPpyq1Qgwufmz24MJ8rlrFKrqbtep l1ZPGkDZp62TgPZsDKOX6aupcZiAhvszQgKJODe0ECjCqaLjw77ifvgxAFVPo7g8qsMq Rz9avwgGN7DXplJzzm1djbJ7Fxlp0LRw+JjS27nnh7PX6HeuGRE+yYtazUKzHpwBlgN8 TpWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="vxA3ZW/x"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16si23411452otq.92.2020.01.22.05.25.04; Wed, 22 Jan 2020 05:25:18 -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=@kernel.org header.s=default header.b="vxA3ZW/x"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730225AbgAVNWw (ORCPT + 99 others); Wed, 22 Jan 2020 08:22:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:40710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730652AbgAVNWu (ORCPT ); Wed, 22 Jan 2020 08:22:50 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 99E402468D; Wed, 22 Jan 2020 13:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699370; bh=nKIIHxRQoPuYzADYCCfZIBNX/f5+mmAUG6fCVypOrqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vxA3ZW/xuAAZlwj8OqbrzIALE/lN7WCJ8I0rURRvkHLmUx024SmKfVFNYlSKBDunL cXXHsyV+RDHbDy2yHyqAkky5zTuoH5Ytqrw+aRy8yCHdAxQid5JLuUjAJd+9eAoo6p lU2i460g4sQfbNJSw2HXjRO53fyFpuc6v9EVOzgQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+4c3cc6dbe7259dbf9054@syzkaller.appspotmail.com, Jozsef Kadlecsik , Cong Wang , Pablo Neira Ayuso Subject: [PATCH 5.4 124/222] netfilter: fix a use-after-free in mtype_destroy() Date: Wed, 22 Jan 2020 10:28:30 +0100 Message-Id: <20200122092842.631271349@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Greg Kroah-Hartman --- 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 @@ -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;