Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: bridge: fix stale eth hdr pointer in br_dev_xmit

In br_dev_xmit() we perform vlan filtering in br_allowed_ingress() but
if the packet has the vlan header inside (e.g. bridge with disabled
tx-vlan-offload) then the vlan filtering code will use skb_vlan_untag()
to extract the vid before filtering which in turn calls pskb_may_pull()
and we may end up with a stale eth pointer. Moreover the cached eth header
pointer will generally be wrong after that operation. Remove the eth header
caching and just use eth_hdr() directly, the compiler does the right thing
and calculates it only once so we don't lose anything.

Fixes: 057658cb33fb ("bridge: suppress arp pkts on BR_NEIGH_SUPPRESS ports")
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Nikolay Aleksandrov and committed by
David S. Miller
823d81b0 e4686c2d

+2 -4
+2 -4
net/bridge/br_device.c
··· 34 34 const struct nf_br_ops *nf_ops; 35 35 u8 state = BR_STATE_FORWARDING; 36 36 const unsigned char *dest; 37 - struct ethhdr *eth; 38 37 u16 vid = 0; 39 38 40 39 rcu_read_lock(); ··· 53 54 BR_INPUT_SKB_CB(skb)->frag_max_size = 0; 54 55 55 56 skb_reset_mac_header(skb); 56 - eth = eth_hdr(skb); 57 57 skb_pull(skb, ETH_HLEN); 58 58 59 59 if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &vid, &state)) 60 60 goto out; 61 61 62 62 if (IS_ENABLED(CONFIG_INET) && 63 - (eth->h_proto == htons(ETH_P_ARP) || 64 - eth->h_proto == htons(ETH_P_RARP)) && 63 + (eth_hdr(skb)->h_proto == htons(ETH_P_ARP) || 64 + eth_hdr(skb)->h_proto == htons(ETH_P_RARP)) && 65 65 br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED)) { 66 66 br_do_proxy_suppress_arp(skb, br, vid, NULL); 67 67 } else if (IS_ENABLED(CONFIG_IPV6) &&