]> git.proxmox.com Git - mirror_ubuntu-eoan-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)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 10 Oct 2018 04:59:09 +0000 (21:59 -0700)
commit2972495699320229b55b8e5065a310be5c81485b
tree817a6d59427a927677f69f6efe97d5f98e6f1267
parente0aa5cf5919ee272732fce9576222e58e48622ab
net: fix generic XDP to handle if eth header was mangled

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>
net/core/dev.c