]> git.ipfire.org Git - people/arne_f/kernel.git/commit
net: fix generic XDP to handle if eth header was mangled
authorJesper Dangaard Brouer <brouer@redhat.com>
Tue, 9 Oct 2018 10:04:43 +0000 (12:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Nov 2019 07:20:54 +0000 (08:20 +0100)
commit312de5a09d10d15984082b5c3e9e5e358386f51a
tree8233a7a278d4217ec58cd55c59102867d1b2f4c3
parent014045888a74981dbf085163216af84bb2a0c60c
net: fix generic XDP to handle if eth header was mangled

[ Upstream commit 2972495699320229b55b8e5065a310be5c81485b ]

XDP can modify (and resize) the Ethernet header in the packet.

There is a bug in generic-XDP, because skb->protocol and skb->pkt_type
are setup before reaching (netif_receive_)generic_xdp.

This bug was hit when XDP were popping VLAN headers (changing
eth->h_proto), as skb->protocol still contains VLAN-indication
(ETH_P_8021Q) causing invocation of skb_vlan_untag(skb), which corrupt
the packet (basically popping the VLAN again).

This patch catch if XDP changed eth header in such a way, that SKB
fields needs to be updated.

V2: on request from Song Liu, use ETH_HLEN instead of mac_len,
in __skb_push() as eth_type_trans() use ETH_HLEN in paired skb_pull_inline().

Fixes: d445516966dc ("net: xdp: support xdp generic on virtual devices")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/core/dev.c