Skip to content

Commit

Permalink
vxlan: fix a use after free in vxlan_encap_bypass
Browse files Browse the repository at this point in the history
when netif_rx() is done, the netif_rx handled skb maybe be freed,
and should not be used.

Signed-off-by: Li RongQing <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Li RongQing authored and davem330 committed Oct 16, 2014
1 parent 4e8febd commit ce6502a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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++;
}
}

Expand Down

0 comments on commit ce6502a

Please sign in to comment.