Skip to contentSkip to conversation

RDMA/hns: Add a check for current state before modifying QP

PATCH Superseded Weihang Li 2 participants 3 messages Aug 17, 2020 – Aug 25, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Weihang Li

author
#0 lore raw

PATCH 1/1 RDMA/hns: Add a check for current state before modifying QP

From: Lang Cheng <[email protected]>

It should be considered as 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.

---
 drivers/infiniband/hw/hns/hns_roce_qp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +4 -2
index e94ca13..bb87e5fc 100644
@@ -1162,8 +1162,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 &&
Signature · 1 line
2.8.1
maintainer
#1 lore raw
Quoted 8 lines · Weihang Li

From: Lang Cheng <[email protected]>

It should be considered as 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.

Quoted 5 lines
---
 drivers/infiniband/hw/hns/hns_roce_qp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

This looks like it needs a fixes line?

Jason

author
#2 lore raw
Quoted 15 lines · Jason Gunthorpe
Quoted 8 lines · Weihang Li

From: Lang Cheng <[email protected]>

It should be considered as 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.

Quoted 5 lines
---
 drivers/infiniband/hw/hns/hns_roce_qp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 4 lines

This looks like it needs a fixes line?

Jason

Thanks for your reminder, will add a fixes tag and send a new version.

Weihang