From mboxrd@z Thu Jan 1 00:00:00 1970 From: roy.qing.li@gmail.com Subject: [PATCH] vxlan: fix a use after free in vxlan_encap_bypass Date: Thu, 16 Oct 2014 08:49:41 +0800 Message-ID: <1413420581-12989-1-git-send-email-roy.qing.li@gmail.com> To: netdev@vger.kernel.org Return-path: Received: from mail-pa0-f44.google.com ([209.85.220.44]:63396 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750820AbaJPAts (ORCPT ); Wed, 15 Oct 2014 20:49:48 -0400 Received: by mail-pa0-f44.google.com with SMTP id et14so2354600pad.3 for ; Wed, 15 Oct 2014 17:49:48 -0700 (PDT) Received: from localhost ([106.120.101.38]) by mx.google.com with ESMTPSA id fk10sm18188537pdb.49.2014.10.15.17.49.46 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 15 Oct 2014 17:49:47 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: From: Li RongQing when netif_rx() is done, the netif_rx handled skb maybe be freed, and should not be used. Signed-off-by: Li RongQing --- drivers/net/vxlan.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 6f83be7..f677cd0 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1668,6 +1668,8 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, struct pcpu_sw_netstats *tx_stats, *rx_stats; 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; tx_stats = this_cpu_ptr(src_vxlan->dev->tstats); rx_stats = this_cpu_ptr(dst_vxlan->dev->tstats); @@ -1691,16 +1693,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++; } } -- 1.7.10.4