public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] netdevsim: drop PSP ext ref on forward failure
@ 2026-03-17  6:14 Wesley Atwell
  2026-03-17 11:11 ` Daniel Zahka
  2026-03-19  0:44 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Wesley Atwell @ 2026-03-17  6:14 UTC (permalink / raw)
  To: kuba, andrew+netdev, davem, edumazet, pabeni
  Cc: willemb, daniel.zahka, netdev, linux-kernel, Wesley Atwell

nsim_do_psp() takes an extra reference to the PSP skb extension so the
extension survives __dev_forward_skb(). That forward path scrubs the skb
and drops attached skb extensions before nsim_psp_handle_ext() can
reattach the PSP metadata.

If __dev_forward_skb() fails in nsim_forward_skb(), the function returns
before nsim_psp_handle_ext() can attach that extension to the skb, leaving
the extra reference leaked.

Drop the saved PSP extension reference before returning from the
forward-failure path. Guard the put because plain or non-decapsulated
traffic can also fail forwarding without ever taking the extra PSP
reference.

Fixes: f857478d6206 ("netdevsim: a basic test PSP implementation")
Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
---
 drivers/net/netdevsim/netdev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 5ec028a00c6200ee6de2e931a2040d56f9523006..3645ebde049a0245febbd454151745675ef80b23 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -109,8 +109,11 @@ static int nsim_forward_skb(struct net_device *tx_dev,
 	int ret;
 
 	ret = __dev_forward_skb(rx_dev, skb);
-	if (ret)
+	if (ret) {
+		if (psp_ext)
+			__skb_ext_put(psp_ext);
 		return ret;
+	}
 
 	nsim_psp_handle_ext(skb, psp_ext);
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] netdevsim: drop PSP ext ref on forward failure
  2026-03-17  6:14 [PATCH net] netdevsim: drop PSP ext ref on forward failure Wesley Atwell
@ 2026-03-17 11:11 ` Daniel Zahka
  2026-03-19  0:44 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Zahka @ 2026-03-17 11:11 UTC (permalink / raw)
  To: Wesley Atwell, kuba, andrew+netdev, davem, edumazet, pabeni
  Cc: willemb, netdev, linux-kernel


On 3/17/26 02:14, Wesley Atwell wrote:
> nsim_do_psp() takes an extra reference to the PSP skb extension so the
> extension survives __dev_forward_skb(). That forward path scrubs the skb
> and drops attached skb extensions before nsim_psp_handle_ext() can
> reattach the PSP metadata.
>
> If __dev_forward_skb() fails in nsim_forward_skb(), the function returns
> before nsim_psp_handle_ext() can attach that extension to the skb, leaving
> the extra reference leaked.
>
> Drop the saved PSP extension reference before returning from the
> forward-failure path. Guard the put because plain or non-decapsulated
> traffic can also fail forwarding without ever taking the extra PSP
> reference.
>
> Fixes: f857478d6206 ("netdevsim: a basic test PSP implementation")
> Signed-off-by: Wesley Atwell <atwellwea@gmail.com>


Reviewed-by: Daniel Zahka <daniel.zahka@gmail.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] netdevsim: drop PSP ext ref on forward failure
  2026-03-17  6:14 [PATCH net] netdevsim: drop PSP ext ref on forward failure Wesley Atwell
  2026-03-17 11:11 ` Daniel Zahka
@ 2026-03-19  0:44 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-19  0:44 UTC (permalink / raw)
  To: Wesley Atwell
  Cc: kuba, andrew+netdev, davem, edumazet, pabeni, willemb,
	daniel.zahka, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 17 Mar 2026 00:14:31 -0600 you wrote:
> nsim_do_psp() takes an extra reference to the PSP skb extension so the
> extension survives __dev_forward_skb(). That forward path scrubs the skb
> and drops attached skb extensions before nsim_psp_handle_ext() can
> reattach the PSP metadata.
> 
> If __dev_forward_skb() fails in nsim_forward_skb(), the function returns
> before nsim_psp_handle_ext() can attach that extension to the skb, leaving
> the extra reference leaked.
> 
> [...]

Here is the summary with links:
  - [net] netdevsim: drop PSP ext ref on forward failure
    https://git.kernel.org/netdev/net/c/7d9351435ebb

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-19  0:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17  6:14 [PATCH net] netdevsim: drop PSP ext ref on forward failure Wesley Atwell
2026-03-17 11:11 ` Daniel Zahka
2026-03-19  0:44 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox