netdevsim: drop PSP ext ref on forward failure
Subsystems (3)
PATCH 1/1 netdevsim: drop PSP ext ref on forward failure
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.
--- drivers/net/netdevsim/netdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/netdevsim/netdev.c +4 -1
@@ -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);
Quoted 9 lines · 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 beforensim_psp_handle_ext()can reattach the PSP metadata.If
__dev_forward_skb()fails innsim_forward_skb(), the function returns beforensim_psp_handle_ext()can attach that extension to the skb, leaving the extra reference leaked.
Quoted 7 lines
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 <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · 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 beforensim_psp_handle_ext()can reattach the PSP metadata.If
__dev_forward_skb()fails innsim_forward_skb(), the function returns beforensim_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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html