lkml.org 
[lkml]   [2020]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.8 332/633] RDMA/hns: Add a check for current state before modifying QP
    Date
    From: Lang Cheng <chenglang@huawei.com>

    [ Upstream commit e0ef0f68c4c0d85b1eb63f38d5d10324361280e8 ]

    It should be considered an illegal operation if the ULP attempts to modify
    a QP from another state to the current hardware state. Otherwise, the ULP
    can modify some fields of QPC at any time. For example, for a QP in state
    of RTS, modify it from RTR to RTS can change the PSN, which is always not
    as expected.

    Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver")
    Link: https://lore.kernel.org/r/1598353674-24270-1-git-send-email-liweihang@huawei.com
    Signed-off-by: Lang Cheng <chenglang@huawei.com>
    Signed-off-by: Weihang Li <liweihang@huawei.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/infiniband/hw/hns/hns_roce_qp.c | 6 ++++--
    1 file changed, 4 insertions(+), 2 deletions(-)

    diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
    index 4edea397b6b80..4486c9b7c3e43 100644
    --- a/drivers/infiniband/hw/hns/hns_roce_qp.c
    +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
    @@ -1171,8 +1171,10 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,

    mutex_lock(&hr_qp->mutex);

    - cur_state = attr_mask & IB_QP_CUR_STATE ?
    - attr->cur_qp_state : (enum ib_qp_state)hr_qp->state;
    + if (attr_mask & IB_QP_CUR_STATE && attr->cur_qp_state != hr_qp->state)
    + goto out;
    +
    + cur_state = hr_qp->state;
    new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;

    if (ibqp->uobject &&
    --
    2.25.1


    \
     
     \ /
      Last update: 2020-10-27 16:11    [W:2.735 / U:2.444 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site