Skip to content

Commit ce6502a

Browse files
Li RongQingdavem330
Li RongQing
authored andcommitted
vxlan: fix a use after free in vxlan_encap_bypass
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]>
1 parent 4e8febd commit ce6502a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/net/vxlan.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,8 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
16681668
struct pcpu_sw_netstats *tx_stats, *rx_stats;
16691669
union vxlan_addr loopback;
16701670
union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip;
1671+
struct net_device *dev = skb->dev;
1672+
int len = skb->len;
16711673

16721674
tx_stats = this_cpu_ptr(src_vxlan->dev->tstats);
16731675
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,
16911693

16921694
u64_stats_update_begin(&tx_stats->syncp);
16931695
tx_stats->tx_packets++;
1694-
tx_stats->tx_bytes += skb->len;
1696+
tx_stats->tx_bytes += len;
16951697
u64_stats_update_end(&tx_stats->syncp);
16961698

16971699
if (netif_rx(skb) == NET_RX_SUCCESS) {
16981700
u64_stats_update_begin(&rx_stats->syncp);
16991701
rx_stats->rx_packets++;
1700-
rx_stats->rx_bytes += skb->len;
1702+
rx_stats->rx_bytes += len;
17011703
u64_stats_update_end(&rx_stats->syncp);
17021704
} else {
1703-
skb->dev->stats.rx_dropped++;
1705+
dev->stats.rx_dropped++;
17041706
}
17051707
}
17061708

0 commit comments

Comments
 (0)