Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Xingyuan Mo
Wed, 28 Oct 2026 06:22
[PATCH nf] netfilter: nf_tables: fix flow rule leak in nft_delrule() error path
Author: Xingyuan Mo
Date: Wed, 28 Oct 2026 06:22
Date: Wed, 28 Oct 2026 06:22
36 lines
11736 bytes
11736 bytes
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.
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
Re: [PATCH nf] netfilter: nf_tables: fix flow rule leak in nft_delrule() error path
Author: netdev-bot+sinfo
Date: Wed, 28 Oct 2026 06:25
Date: Wed, 28 Oct 2026 06:25
22 lines
8789 bytes
8789 bytes
Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. - Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then. The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Re: [PATCH nf] netfilter: nf_tables: fix flow rule leak in nft_delrule() error path
Author: Pablo Neira Ayuso
Date: Sun, 01 Nov 2026 23:23
Date: Sun, 01 Nov 2026 23:23
42 lines
9973 bytes
9973 bytes
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
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads