Skip to content

Commit 9948170

Browse files
joamakigregkh
authored andcommitted
bpf: Set mac_len in bpf_skb_change_head
[ Upstream commit 84316ca ] 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 <joamaki@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210519154743.2554771-2-joamaki@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 24cb8bb commit 9948170

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎net/core/filter.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3782,6 +3782,7 @@ static inline int __bpf_skb_change_head(struct sk_buff *skb, u32 head_room,
37823782
__skb_push(skb, head_room);
37833783
memset(skb->data, 0, head_room);
37843784
skb_reset_mac_header(skb);
3785+
skb_reset_mac_len(skb);
37853786
}
37863787

37873788
return ret;

0 commit comments

Comments
 (0)