bpf: Set mac_len in bpf_skb_change_head
authorJussi Maki <joamaki@gmail.com>
Wed, 19 May 2021 15:47:42 +0000 (15:47 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Jun 2021 06:36:24 +0000 (08:36 +0200)
commit05a62e373bebbbb20fca05526b1cd5d9d76f9e92
treed11ecd12117a06179d11337cbded7d2b1cf16f59
parent790921f08da5149e15f83685ba73d3738940df9a
bpf: Set mac_len in bpf_skb_change_head

[ Upstream commit 84316ca4e100d8cbfccd9f774e23817cb2059868 ]

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: 3a0af8fd61f9 ("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>
net/core/filter.c