Skip to content

Commit 65a5c22

Browse files
committed
bpf: Fix metadata_dst leak __bpf_redirect_neigh_v{4,6}
jira KERNEL-238 Rebuild_History Non-Buildable kernel-6.12.0-124.16.1.el10_1 commit-author Daniel Borkmann <daniel@iogearbox.net> commit 23f3770 Cilium has a BPF egress gateway feature which forces outgoing K8s Pod traffic to pass through dedicated egress gateways which then SNAT the traffic in order to interact with stable IPs outside the cluster. The traffic is directed to the gateway via vxlan tunnel in collect md mode. A recent BPF change utilized the bpf_redirect_neigh() helper to forward packets after the arrival and decap on vxlan, which turned out over time that the kmalloc-256 slab usage in kernel was ever-increasing. The issue was that vxlan allocates the metadata_dst object and attaches it through a fake dst entry to the skb. The latter was never released though given bpf_redirect_neigh() was merely setting the new dst entry via skb_dst_set() without dropping an existing one first. Fixes: b4ab314 ("bpf: Add redirect_neigh helper as redirect drop-in") Reported-by: Yusuke Suzuki <yusuke.suzuki@isovalent.com> Reported-by: Julian Wiedmann <jwi@isovalent.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Cc: Martin KaFai Lau <martin.lau@kernel.org> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Jordan Rife <jrife@google.com> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Jordan Rife <jrife@google.com> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://lore.kernel.org/r/20251003073418.291171-1-daniel@iogearbox.net Signed-off-by: Alexei Starovoitov <ast@kernel.org> (cherry picked from commit 23f3770) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 3543481 commit 65a5c22

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/core/filter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,7 @@ static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev,
22802280
if (IS_ERR(dst))
22812281
goto out_drop;
22822282

2283+
skb_dst_drop(skb);
22832284
skb_dst_set(skb, dst);
22842285
} else if (nh->nh_family != AF_INET6) {
22852286
goto out_drop;
@@ -2388,6 +2389,7 @@ static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,
23882389
goto out_drop;
23892390
}
23902391

2392+
skb_dst_drop(skb);
23912393
skb_dst_set(skb, &rt->dst);
23922394
}
23932395

0 commit comments

Comments
 (0)