From: Yonglong Liu <liuyonglong@huawei.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxarm@huawei.com>, <salil.mehta@huawei.com>,
<yisen.zhuang@huawei.com>, <shiju.jose@huawei.com>
Subject: [PATCH net 1/6] net: hns: fix KASAN: use-after-free in hns_nic_net_xmit_hw()
Date: Thu, 4 Apr 2019 16:46:42 +0800 [thread overview]
Message-ID: <1554367607-130891-2-git-send-email-liuyonglong@huawei.com> (raw)
In-Reply-To: <1554367607-130891-1-git-send-email-liuyonglong@huawei.com>
From: Liubin Shu <shuliubin@huawei.com>
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>
---
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 60e7d7a..e5a7c07 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -376,8 +376,6 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
wmb(); /* commit all data before submit */
assert(skb->queue_mapping < priv->ae_handle->q_num);
hnae_queue_xmit(priv->ae_handle->qs[skb->queue_mapping], buf_num);
- ring->stats.tx_pkts++;
- ring->stats.tx_bytes += skb->len;
return NETDEV_TX_OK;
@@ -999,6 +997,9 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data,
/* issue prefetch for next Tx descriptor */
prefetch(&ring->desc_cb[ring->next_to_clean]);
}
+ /* update tx ring statistics. */
+ ring->stats.tx_pkts += pkts;
+ ring->stats.tx_bytes += bytes;
NETIF_TX_UNLOCK(ring);
--
2.8.1
next prev parent reply other threads:[~2019-04-04 8:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 8:46 [PATCH net 0/6] net: hns: bugfixes for HNS Driver Yonglong Liu
2019-04-04 8:46 ` Yonglong Liu [this message]
2019-04-04 8:46 ` [PATCH net 2/6] net: hns: Use NAPI_POLL_WEIGHT for hns driver Yonglong Liu
2019-04-04 8:46 ` [PATCH net 3/6] net: hns: Fix probabilistic memory overwrite when HNS driver initialized Yonglong Liu
2019-04-04 8:46 ` [PATCH net 4/6] net: hns: fix ICMP6 neighbor solicitation messages discard problem Yonglong Liu
2019-04-04 8:46 ` [PATCH net 5/6] net: hns: Fix WARNING when remove HNS driver with SMMU enabled Yonglong Liu
2019-04-04 8:46 ` [PATCH net 6/6] net: hns: Fix sparse: some warnings in HNS drivers Yonglong Liu
2019-04-04 17:35 ` [PATCH net 0/6] net: hns: bugfixes for HNS Driver David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1554367607-130891-2-git-send-email-liuyonglong@huawei.com \
--to=liuyonglong@huawei.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=shiju.jose@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).