]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vxlan: fix a use after free in vxlan_encap_bypass
authorLi RongQing <roy.qing.li@gmail.com>
Thu, 16 Oct 2014 00:49:41 +0000 (08:49 +0800)
committerJiri Slaby <jslaby@suse.cz>
Wed, 5 Nov 2014 09:03:20 +0000 (10:03 +0100)
[ Upstream commit ce6502a8f9572179f044a4d62667c4645256d6e4 ]

when netif_rx() is done, the netif_rx handled skb maybe be freed,
and should not be used.

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/vxlan.c

index f1735fb6136276cad43f4a07a60f70eadd8c8089..637e5ad186ef6302aff701447a4359023836934b 100644 (file)
@@ -1683,6 +1683,8 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
        struct pcpu_tstats *rx_stats = this_cpu_ptr(dst_vxlan->dev->tstats);
        union vxlan_addr loopback;
        union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip;
+       struct net_device *dev = skb->dev;
+       int len = skb->len;
 
        skb->pkt_type = PACKET_HOST;
        skb->encapsulation = 0;
@@ -1704,16 +1706,16 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
 
        u64_stats_update_begin(&tx_stats->syncp);
        tx_stats->tx_packets++;
-       tx_stats->tx_bytes += skb->len;
+       tx_stats->tx_bytes += len;
        u64_stats_update_end(&tx_stats->syncp);
 
        if (netif_rx(skb) == NET_RX_SUCCESS) {
                u64_stats_update_begin(&rx_stats->syncp);
                rx_stats->rx_packets++;
-               rx_stats->rx_bytes += skb->len;
+               rx_stats->rx_bytes += len;
                u64_stats_update_end(&rx_stats->syncp);
        } else {
-               skb->dev->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
        }
 }