lkml.org 
[lkml]   [2021]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 065/177] net: hns3: fix use-after-free bug in hclgevf_send_mbx_msg
    Date
    From: Jie Wang <wangjie125@huawei.com>

    [ Upstream commit 27cbf64a766e86f068ce6214f04c00ceb4db1af4 ]

    Currently, the hns3_remove function firstly uninstall client instance,
    and then uninstall acceletion engine device. The netdevice is freed in
    client instance uninstall process, but acceletion engine device uninstall
    process still use it to trace runtime information. This causes a use after
    free problem.

    So fixes it by check the instance register state to avoid use after free.

    Fixes: d8355240cf8f ("net: hns3: add trace event support for PF/VF mailbox")
    Signed-off-by: Jie Wang <wangjie125@huawei.com>
    Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
    index fdc66fae09601..c5ac6ecf36e10 100644
    --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
    +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
    @@ -114,7 +114,8 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev,

    memcpy(&req->msg, send_msg, sizeof(struct hclge_vf_to_pf_msg));

    - trace_hclge_vf_mbx_send(hdev, req);
    + if (test_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state))
    + trace_hclge_vf_mbx_send(hdev, req);

    /* synchronous send */
    if (need_resp) {
    --
    2.33.0


    \
     
     \ /
      Last update: 2021-12-20 15:59    [W:4.124 / U:0.104 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site