Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1417777imm; Thu, 5 Jul 2018 23:02:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcKw8rWzVJdPopCQgsLcHCAElS6dMqi8JR0ToVVKQJIJZWmLXO5Ug13g8cxqmVbStlEIDCt X-Received: by 2002:a62:3c4f:: with SMTP id j76-v6mr9349216pfa.119.1530856940069; Thu, 05 Jul 2018 23:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530856940; cv=none; d=google.com; s=arc-20160816; b=ZYOOF89HaDSJ8uJ+87KRf136Tn+MzgIZ1SlZahm8XUjvSxGjE/hPQmZC8Y3nJJoqkE 6jIjxgI/U+JksEGsdmvDJFsenGjpNCp3aItOj25J+lUbaMexgU0xqvaQSuM3nfHOFPG4 zAn3rPyCr7c69ntSDMNgG6ZA2PUw0O/E1SQwJljbAt+5Xvxr3HqTdhCYOMub+9Ongmoy bI97OqwpyhFVLmj/iPYRTwPTFHV6su+Pl2USifUlGmygN3o5UUb4yWhp0cIVt8uBxyqG xq7x8J8j9aeYCGokbA/WoDMD7zT6B0E3/f8OXx58Xkho+9H8dgxG8y/8VFES60OXMCbG 3gwA== 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 :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wR7bEQgG3GCbNgs5T2QPbRaPJBM2vAVVXiMPjEXln/Y=; b=UTcYGX+OqQtb184Ia1axPhJhJnqB0rD50PjjJVGqvHPyPY/odX6STKEubZU658meIO OCjuvCFb1m3Tfbl9deCWYWGz2GkDdLwK2nOK7Enkh9rtAzNdlvcPHm+M9Rkt4tRVa4iz Omjc6ci3GHBzMfbKPU6yFh6HDLfV5YtexUW1iy//UTEo3i0U/d7ceiIry9B0srhaimpU HLSIg04C9FYG9MswVHeGEVCb/lff1M1b+rAVdfr+XkB15URQyjo688BkbuDSdlQ5UYU+ HB528Mxy0hjA2pCQttY+YBAcx8fuyn2Zr+siUNt2VghlUYfp9DPYdYjBTPGyWRlfWAl5 +Pzw== ARC-Authentication-Results: i=1; mx.google.com; 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 t22-v6si7344879plo.263.2018.07.05.23.02.05; Thu, 05 Jul 2018 23:02:20 -0700 (PDT) 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; 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 S934156AbeGFFvJ (ORCPT + 99 others); Fri, 6 Jul 2018 01:51:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33188 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934136AbeGFFvG (ORCPT ); Fri, 6 Jul 2018 01:51:06 -0400 Received: from localhost (D57D388D.static.ziggozakelijk.nl [213.125.56.141]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 99A4286A; Fri, 6 Jul 2018 05:51:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Pablo Neira Ayuso Subject: [PATCH 4.14 31/61] netfilter: nf_tables: fix memory leak on error exit return Date: Fri, 6 Jul 2018 07:46:55 +0200 Message-Id: <20180706054713.526522396@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706054712.332416244@linuxfoundation.org> References: <20180706054712.332416244@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Colin Ian King commit f0dfd7a2b35b02030949100247d851b793cb275f upstream. Currently the -EBUSY error return path is not free'ing resources allocated earlier, leaving a memory leak. Fix this by exiting via the error exit label err5 that performs the necessary resource clean up. Detected by CoverityScan, CID#1432975 ("Resource leak") Fixes: 9744a6fcefcb ("netfilter: nf_tables: check if same extensions are set when adding elements") Signed-off-by: Colin Ian King Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -3999,8 +3999,10 @@ static int nft_add_set_elem(struct nft_c if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA) ^ nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) || nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF) ^ - nft_set_ext_exists(ext2, NFT_SET_EXT_OBJREF)) - return -EBUSY; + nft_set_ext_exists(ext2, NFT_SET_EXT_OBJREF)) { + err = -EBUSY; + goto err5; + } if ((nft_set_ext_exists(ext, NFT_SET_EXT_DATA) && nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) && memcmp(nft_set_ext_data(ext),