Skip to content

Commit 84316ca

Browse files
joamakiborkmann
authored andcommitted
bpf: Set mac_len in bpf_skb_change_head
The skb_change_head() helper did not set "skb->mac_len", which is problematic when it's used in combination with skb_redirect_peer(). Without it, redirecting a packet from a L3 device such as wireguard to the veth peer device will cause skb->data to point to the middle of the IP header on entry to tcp_v4_rcv() since the L2 header is not pulled correctly due to mac_len=0. Fixes: 3a0af8f ("bpf: BPF for lightweight tunnel infrastructure") Signed-off-by: Jussi Maki <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent ceb1167 commit 84316ca

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/core/filter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3784,6 +3784,7 @@ static inline int __bpf_skb_change_head(struct sk_buff *skb, u32 head_room,
37843784
__skb_push(skb, head_room);
37853785
memset(skb->data, 0, head_room);
37863786
skb_reset_mac_header(skb);
3787+
skb_reset_mac_len(skb);
37873788
}
37883789

37893790
return ret;

0 commit comments

Comments
 (0)