net: hns: fix KASAN: use-after-free in hns_nic_net_xmit_hw()
commitb36a29e554207428f889249170b45dfeff71931b
authorLiubin Shu <shuliubin@huawei.com>
Thu, 4 Apr 2019 08:46:42 +0000 (4 16:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 May 2019 05:19:10 +0000 (8 07:19 +0200)
tree7f15cee52e73583d69c0389ab60153c31e03d2bf
parent9cdaf16efabddb9a839157a1a4b7a716b1e38978
net: hns: fix KASAN: use-after-free in hns_nic_net_xmit_hw()

[ Upstream commit 3a39a12ad364a9acd1038ba8da67cd8430f30de4 ]

This patch is trying to fix the issue due to:
[27237.844750] BUG: KASAN: use-after-free in hns_nic_net_xmit_hw+0x708/0xa18[hns_enet_drv]

After hnae_queue_xmit() in hns_nic_net_xmit_hw(), can be
interrupted by interruptions, and than call hns_nic_tx_poll_one()
to handle the new packets, and free the skb. So, when turn back to
hns_nic_net_xmit_hw(), calling skb->len will cause use-after-free.

This patch update tx ring statistics in hns_nic_tx_poll_one() to
fix the bug.

Signed-off-by: Liubin Shu <shuliubin@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/hisilicon/hns/hns_enet.c