From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3386DC47254 for ; Fri, 8 May 2020 12:44:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C4C620720 for ; Fri, 8 May 2020 12:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588941855; bh=zleLaBM0XPingcVsYTc+5kLlHBiQnOAVwWkAMGN0/Pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=f0yp5Z8NQd5pqJe4izTnvL434Hu1rvc3iw63Pjx6gTxljF7CNiSGyVseBR8f9voGs XTJWTsaQ1Z4wT5JPJ37/1YIGUjynwbnFp063RLmojh/CWKphba4HU0vPkxKCri0O9t VjUu3cqp9t1+7shSbyalYFWTSrwLfZGymvHy1o8I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727970AbgEHMoN (ORCPT ); Fri, 8 May 2020 08:44:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:42490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729163AbgEHMoM (ORCPT ); Fri, 8 May 2020 08:44:12 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 BFD5B206B8; Fri, 8 May 2020 12:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588941852; bh=zleLaBM0XPingcVsYTc+5kLlHBiQnOAVwWkAMGN0/Pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qy3BiNyv5icMfm6+daafLmlETh3dyntaxnmAbMuFWtlZWx1wm+ELGzmA9B8ELwEz/ QWi/B2z+2CR+84vFyOhVPbO9iv7TfHZiqsWZGUCAyXhjeelLJtKOnlXhZp0CbvbXB/ Y3bQf4Kj0mSLdL33rGFdRHx65HwxqmqTscIp6KVE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liping Zhang , Pablo Neira Ayuso Subject: [PATCH 4.4 199/312] netfilter: nf_tables: destroy the set if fail to add transaction Date: Fri, 8 May 2020 14:33:10 +0200 Message-Id: <20200508123138.434155611@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200508123124.574959822@linuxfoundation.org> References: <20200508123124.574959822@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Liping Zhang commit c17c3cdff10b9f59ef1244a14604f10949f17117 upstream. When the memory is exhausted, then we will fail to add the NFT_MSG_NEWSET transaction. In such case, we should destroy the set before we free it. Fixes: 958bee14d071 ("netfilter: nf_tables: use new transaction infrastructure to handle sets") Signed-off-by: Liping Zhang Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -2849,12 +2849,14 @@ static int nf_tables_newset(struct net * err = nft_trans_set_add(&ctx, NFT_MSG_NEWSET, set); if (err < 0) - goto err2; + goto err3; list_add_tail_rcu(&set->list, &table->sets); table->use++; return 0; +err3: + ops->destroy(set); err2: kfree(set); err1: