From: Wentao Liang <vulab@iscas.ac.cn>
To: coreteam@netfilter.org
Cc: davem@davemloft.net, edumazet@google.com, fw@strlen.de,
horms@kernel.org, kuba@kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
pabeni@redhat.com, pablo@netfilter.org, phil@nwl.cc,
wenxu@ucloud.cn, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] netfilter: nf_dup_netdev: Fix net_device reference leak in nft_fwd_dup_netdev_offload()
Date: Wed, 16 Sep 2026 07:36:27 +0000 [thread overview]
Message-ID: <20260916073627.1971921-1-vulab@iscas.ac.cn> (raw)
In nft_fwd_dup_netdev_offload(), dev_get_by_index() gets a reference to
the net_device corresponding to oif. When nft_flow_action_entry_next()
fails (returning NULL), the function returns -E2BIG directly without
dropping the net_device reference via dev_put(), causing a reference
leak.
Add dev_put(dev) before returning -E2BIG on failure.
Fixes: be2861dc36d7 ("netfilter: nft_{fwd,dup}_netdev: add offload support")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
net/netfilter/nf_dup_netdev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nf_dup_netdev.c b/net/netfilter/nf_dup_netdev.c
index 3b0a70e154cd..dd627b7d72d9 100644
--- a/net/netfilter/nf_dup_netdev.c
+++ b/net/netfilter/nf_dup_netdev.c
@@ -80,8 +80,10 @@ int nft_fwd_dup_netdev_offload(struct nft_offload_ctx *ctx,
return -EOPNOTSUPP;
entry = nft_flow_action_entry_next(ctx, flow);
- if (!entry)
+ if (!entry) {
+ dev_put(dev);
return -E2BIG;
+ }
entry->id = id;
entry->dev = dev;
--
2.34.1
next reply other threads:[~2026-09-16 7:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 7:36 Wentao Liang [this message]
2026-09-16 8:41 ` [PATCH] netfilter: nf_dup_netdev: Fix net_device reference leak in nft_fwd_dup_netdev_offload() Xuanqiang Luo
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=20260916073627.1971921-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--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=pablo@netfilter.org \
--cc=phil@nwl.cc \
--cc=stable@vger.kernel.org \
--cc=wenxu@ucloud.cn \
/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