netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Jozsef Kadlecsik <kadlec@netfilter.org>,
	Florian Westphal <fw@strlen.de>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	Network Development <netdev@vger.kernel.org>
Subject: Re: [PATCH] netfilter: nf_tables: fix percpu memory leak at nf_tables_addchain()
Date: Mon, 12 Sep 2022 16:17:34 +0200	[thread overview]
Message-ID: <Yx8/frbK9hxF8290@salvia> (raw)
In-Reply-To: <41e415f2-3ca4-8e8a-a4b5-5044e7043131@I-love.SAKURA.ne.jp>

On Mon, Sep 12, 2022 at 10:58:51PM +0900, Tetsuo Handa wrote:
> It seems to me that percpu memory for chain stats started leaking since
> commit 3bc158f8d0330f0a ("netfilter: nf_tables: map basechain priority to
> hardware priority") when nft_chain_offload_priority() returned an error.

Patch also LGTM. Thanks.

> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Fixes: 3bc158f8d0330f0a ("netfilter: nf_tables: map basechain priority to hardware priority")
> ---
> The "netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain()" made
> me wonder where free_percpu() is called when nft_basechain_init() returned an error. But I
> don't know whether this patch is correct. Please check carefully.
>
>  net/netfilter/nf_tables_api.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index e062754dc6cc..63c70141b3e5 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -2243,6 +2243,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
>  		if (err < 0) {
>  			nft_chain_release_hook(&hook);
>  			kfree(basechain);
> +			free_percpu(stats);
>  			return err;
>  		}
>  		if (stats)
> -- 
> 2.18.4

  reply	other threads:[~2022-09-12 14:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12 13:58 [PATCH] netfilter: nf_tables: fix percpu memory leak at nf_tables_addchain() Tetsuo Handa
2022-09-12 14:17 ` Pablo Neira Ayuso [this message]
2022-09-15 20:20 ` Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yx8/frbK9hxF8290@salvia \
    --to=pablo@netfilter.org \
    --cc=coreteam@netfilter.org \
    --cc=fw@strlen.de \
    --cc=kadlec@netfilter.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).