* [PATCH] netfilter: nf_dup_netdev: Fix net_device reference leak in nft_fwd_dup_netdev_offload()
@ 2026-09-16 7:36 Wentao Liang
2026-09-16 8:41 ` Xuanqiang Luo
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16 7:36 UTC (permalink / raw)
To: coreteam
Cc: davem, edumazet, fw, horms, kuba, linux-kernel, netdev,
netfilter-devel, pabeni, pablo, phil, wenxu, Wentao Liang,
stable
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] netfilter: nf_dup_netdev: Fix net_device reference leak in nft_fwd_dup_netdev_offload()
2026-09-16 7:36 [PATCH] netfilter: nf_dup_netdev: Fix net_device reference leak in nft_fwd_dup_netdev_offload() Wentao Liang
@ 2026-09-16 8:41 ` Xuanqiang Luo
0 siblings, 0 replies; 2+ messages in thread
From: Xuanqiang Luo @ 2026-09-16 8:41 UTC (permalink / raw)
To: Wentao Liang
Cc: davem, edumazet, fw, horms, kuba, linux-kernel, netdev,
netfilter-devel, pabeni, pablo, phil, wenxu, stable, coreteam
在 2026/9/16 15:36, Wentao Liang 写道:
> 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;
Please update your local tree.
Florian Westphal has already fixed this issue:
https://lore.kernel.org/all/20260605114715.11297-1-fw@strlen.de/
Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-16 8:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 7:36 [PATCH] netfilter: nf_dup_netdev: Fix net_device reference leak in nft_fwd_dup_netdev_offload() Wentao Liang
2026-09-16 8:41 ` Xuanqiang Luo
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®