Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH net v1] bpf: lwt: Fix dst reference leak on reroute failure
@ 2026-07-23  6:04 xuanqiang.luo
  2026-07-28 11:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: xuanqiang.luo @ 2026-07-23  6:04 UTC (permalink / raw)
  To: netdev, bpf
  Cc: davem, edumazet, kuba, pabeni, horms, idosch, daniel, ast,
	martin.lau, posk, Xuanqiang Luo, stable

From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>

bpf_lwt_xmit_reroute() obtains a referenced dst from the route
lookup. When skb_cow_head() fails before that dst is installed on the
skb, the error path only frees the skb. The skb still owns its previous
dst, so the newly looked up dst reference is leaked.

Release the new dst reference before freeing the skb on this error
path.

Fixes: 3bd0b15281af ("bpf: add handling of BPF_LWT_REROUTE to lwt_bpf.c")
Cc: stable@vger.kernel.org
Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
---
 net/core/lwt_bpf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index bf588f508b79e..652952d416f23 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -255,8 +255,10 @@ static int bpf_lwt_xmit_reroute(struct sk_buff *skb)
 	 * if there is enough header space in skb.
 	 */
 	err = skb_cow_head(skb, LL_RESERVED_SPACE(dst->dev));
-	if (unlikely(err))
+	if (unlikely(err)) {
+		dst_release(dst);
 		goto err;
+	}
 
 	skb_dst_drop(skb);
 	skb_dst_set(skb, dst);
-- 
2.43.0


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

* Re: [PATCH net v1] bpf: lwt: Fix dst reference leak on reroute failure
  2026-07-23  6:04 [PATCH net v1] bpf: lwt: Fix dst reference leak on reroute failure xuanqiang.luo
@ 2026-07-28 11:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-28 11:30 UTC (permalink / raw)
  To: luoxuanqiang
  Cc: netdev, bpf, davem, edumazet, kuba, pabeni, horms, idosch, daniel,
	ast, martin.lau, posk, luoxuanqiang, stable

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Thu, 23 Jul 2026 14:04:45 +0800 you wrote:
> From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
> 
> bpf_lwt_xmit_reroute() obtains a referenced dst from the route
> lookup. When skb_cow_head() fails before that dst is installed on the
> skb, the error path only frees the skb. The skb still owns its previous
> dst, so the newly looked up dst reference is leaked.
> 
> [...]

Here is the summary with links:
  - [net,v1] bpf: lwt: Fix dst reference leak on reroute failure
    https://git.kernel.org/netdev/net/c/88c17de85ddb

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] 2+ messages in thread

end of thread, other threads:[~2026-07-28 11:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23  6:04 [PATCH net v1] bpf: lwt: Fix dst reference leak on reroute failure xuanqiang.luo
2026-07-28 11:30 ` 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