linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-next] RDMA/hns: Add a check for current state before modifying QP
@ 2020-08-17 11:58 Weihang Li
  2020-08-24 17:16 ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Weihang Li @ 2020-08-17 11:58 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

From: Lang Cheng <chenglang@huawei.com>

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.

Signed-off-by: Lang Cheng <chenglang@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 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 e94ca13..bb87e5fc 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -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 &&
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-next] RDMA/hns: Add a check for current state before modifying QP
  2020-08-17 11:58 [PATCH for-next] RDMA/hns: Add a check for current state before modifying QP Weihang Li
@ 2020-08-24 17:16 ` Jason Gunthorpe
  2020-08-25  1:23   ` liweihang
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2020-08-24 17:16 UTC (permalink / raw)
  To: Weihang Li; +Cc: dledford, leon, linux-rdma, linuxarm

On Mon, Aug 17, 2020 at 07:58:52PM +0800, Weihang Li wrote:
> From: Lang Cheng <chenglang@huawei.com>
> 
> 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.
> 
> Signed-off-by: Lang Cheng <chenglang@huawei.com>
> Signed-off-by: Weihang Li <liweihang@huawei.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-next] RDMA/hns: Add a check for current state before modifying QP
  2020-08-24 17:16 ` Jason Gunthorpe
@ 2020-08-25  1:23   ` liweihang
  0 siblings, 0 replies; 3+ messages in thread
From: liweihang @ 2020-08-25  1:23 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: dledford, leon, linux-rdma, Linuxarm

On 2020/8/25 1:17, Jason Gunthorpe wrote:
> On Mon, Aug 17, 2020 at 07:58:52PM +0800, Weihang Li wrote:
>> From: Lang Cheng <chenglang@huawei.com>
>>
>> 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.
>>
>> Signed-off-by: Lang Cheng <chenglang@huawei.com>
>> Signed-off-by: Weihang Li <liweihang@huawei.com>
>> ---
>>  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
> 

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

Weihang

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-25  1:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 11:58 [PATCH for-next] RDMA/hns: Add a check for current state before modifying QP Weihang Li
2020-08-24 17:16 ` Jason Gunthorpe
2020-08-25  1:23   ` liweihang

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).