From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Xingyuan Mo <hdthky0@gmail.com>
Cc: Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
"open list:NETFILTER" <netfilter-devel@vger.kernel.org>,
"open list:NETFILTER" <coreteam@netfilter.org>,
"open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH nf] netfilter: nf_tables: fix flow rule leak in nft_delrule() error path
Date: Mon, 2 Nov 2026 00:23:55 +0100 [thread overview]
Message-ID: <aufKCw9iv5pMj2fy@chamomile> (raw)
In-Reply-To: <20261028062204.1079089-1-hdthky0@gmail.com>
On Wed, Oct 28, 2026 at 02:22:42PM +0800, Xingyuan Mo wrote:
> On the nf_tables_delrule_deactivate() failure path, nft_trans_destroy()
> frees the transaction but not the attached HW offload flow rule. Destroy
> the flow after the transaction to avoid memory leak.
For the record, alternative proposed patch:
https://patch.msgid.link/netfilter-devel/20261028112535.115054-1-pablo@netfilter.org
> Fixes: 63b48c73ff56 ("netfilter: nf_tables_offload: undo updates if transaction fails")
> Assisted-by: opencode:deepseek-v4
> Signed-off-by: Xingyuan Mo <hdthky0@gmail.com>
> ---
> net/netfilter/nf_tables_api.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index 59ac623e6805..ec56ea8c8436 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -752,7 +752,7 @@ static struct nft_trans *nft_trans_rule_add(struct nft_ctx *ctx, int msg_type,
>
> static int nft_delrule(struct nft_ctx *ctx, struct nft_rule *rule)
> {
> - struct nft_flow_rule *flow;
> + struct nft_flow_rule *flow = NULL;
> struct nft_trans *trans;
> int err;
>
> @@ -773,6 +773,8 @@ static int nft_delrule(struct nft_ctx *ctx, struct nft_rule *rule)
> err = nf_tables_delrule_deactivate(ctx, rule);
> if (err < 0) {
> nft_trans_destroy(trans);
> + if (flow)
> + nft_flow_rule_destroy(flow);
> return err;
> }
> nft_rule_expr_deactivate(ctx, rule, NFT_TRANS_PREPARE);
> --
> 2.43.0
>
prev parent reply other threads:[~2026-11-01 23:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 6:22 Xingyuan Mo
2026-10-28 6:25 ` netdev-bot+sinfo
2026-11-01 23:23 ` Pablo Neira Ayuso [this message]
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=aufKCw9iv5pMj2fy@chamomile \
--to=pablo@netfilter.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fw@strlen.de \
--cc=hdthky0@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phil@nwl.cc \
/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
all inboxes | Powered by JetHome®