Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2464001yba; Mon, 15 Apr 2019 12:11:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1scSoYvYGHH11NN2NJpjJUezOwM+Mjm2L7nOG21tnEGNX6hS2BJNiCrJ6XM/8luqA9wov X-Received: by 2002:a62:e215:: with SMTP id a21mr76123777pfi.30.1555355478809; Mon, 15 Apr 2019 12:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355478; cv=none; d=google.com; s=arc-20160816; b=dJEaL8C6H6JoXkaCLjjLapLoVKhDaW7b5eUoyVOXrQ20SndoVFwJ8Mi6eGzofnCFL6 Hl8WR03q1ffZ0A9+0oKZOdNNjjfTwUco/zXaiBRUlvWMak/v7Y2vt14k2Ud10MbQP/f0 p8Wrf7Y3AtElWVBC/vGFW1pIRIZlD4DWbnlVItskWoKG/L2K1CNxOveB8VjapYTAp9cM B5OSYfIq2dFZZgyLfQyW/8yEZAc4XCXE+zTF/1QiiMr0WxN99x+3VkO7NeSCfcJhaY7O UlXAzAbIEJ/VR2cU9Rk7PcCNP2G11c6ftxhJATfnCv3IuvCUt0vCiXClr4zsxu1NPLl1 ZoSA== 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=8e60zkSqnvsQz8Vjbr50Rk5Hy9I/zI1Ft5E0EWoGv1E=; b=zvuTRvmm5pJsspasLKVcThkWxbgEiBnwZ7umAx771mIKSuljlVOTrM1u5wjb2bAl6a 7Vj5OGxo/w2J65CfSyn0hVwJNa939xiyjyEOBgoLyEzgSAjH4GNev3cbXwY/SWcMueAx aVhxzoDL4kI8xrjXHvW8s9jTWftM5wIUXccEbpScOcTNNl/yBLwqvAHH5DarQgRAoshk SOOwDNGkFXnEfWS2ANUiOBFtP7dUWLcSOTReHzXzTqJHvkSe7vZP/OKI3YdVDDbsV0wz wVQy1JG/hHK/9pQZ4TT1pAt7JkBxaAJ43t+mMjpEmjQ4XTCHbOK6A8FU3vzNPxlMZTuX hKMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="IXb5P/0D"; 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 1si20160827pls.222.2019.04.15.12.11.02; Mon, 15 Apr 2019 12:11:18 -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; dkim=pass header.i=@kernel.org header.s=default header.b="IXb5P/0D"; 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 S1730780AbfDOTJo (ORCPT + 99 others); Mon, 15 Apr 2019 15:09:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:45438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730192AbfDOTJk (ORCPT ); Mon, 15 Apr 2019 15:09:40 -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 28E3B20651; Mon, 15 Apr 2019 19:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355379; bh=FoJIe2TwdMmVM4gnTTMV6e2QIidGjWXMULXNHmHdmBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IXb5P/0DeJHd/0npKb+hJqrOH/0zdfSykEDNmHvPB/bryj2IkhoZ6NsumQmOxNZd8 K7W07CDUuGwADQozVtA0rbd3fsZjJVYVdcqNx8VdUnosQ+WhjFT7v7Ouf36zWvgfWN 7z1lOY6KzT707AxOVIk2lBPhAkqSimTX/QsriiM0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.0 005/117] netfilter: nf_tables: add missing ->release_ops() in error path of newrule() Date: Mon, 15 Apr 2019 20:59:35 +0200 Message-Id: <20190415183745.166517318@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183744.887851196@linuxfoundation.org> References: <20190415183744.887851196@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 [ Upstream commit b25a31bf0ca091aa8bdb9ab329b0226257568bbe ] ->release_ops() callback releases resources and this is used in error path. If nf_tables_newrule() fails after ->select_ops(), it should release resources. but it can not call ->destroy() because that should be called after ->init(). At this point, ->release_ops() should be used for releasing resources. Test commands: modprobe -rv xt_tcpudp iptables-nft -I INPUT -m tcp <-- error command lsmod Result: Module Size Used by xt_tcpudp 20480 2 <-- it should be 0 Fixes: b8e204006340 ("netfilter: nft_compat: use .release_ops and remove list of extension") Signed-off-by: Taehee Yoo Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_tables_api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index f20b904873c6..acb124ce92ec 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -2753,8 +2753,11 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk, nf_tables_rule_release(&ctx, rule); err1: for (i = 0; i < n; i++) { - if (info[i].ops != NULL) + if (info[i].ops) { module_put(info[i].ops->type->owner); + if (info[i].ops->type->release_ops) + info[i].ops->type->release_ops(info[i].ops); + } } kvfree(info); return err; -- 2.19.1