Skip to contentSkip to conversation

RDMA/rxe: Fix double free in rxe_qp.c

PATCH Applied Bob Pearson 3 participants 5 messages May 15, 2023 – May 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/rxe: Fix double free in rxe_qp.c

A recent patch can cause a double spin_unlock_bh() in rxe_qp_to_attr() at line 715 in rxe_qp.c. This patch corrects that behavior.

A newer patch from Guoqing Jiang recommends replacing all spin_lock calls for qp->state_lock to spin_(un)lock_irqsave(restore)() since apparently the blktests test suite can call the kernel verbs APIs while in hard interrupt state. This patch needs to be applied first and Guoqing's patch modified to accommodate this small change.

Fixes f605f26ea196 ("RDMA/rxe: Protect QP state with qp->state_lock")
---
 drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_qp.c +2 -1
index c5451a4488ca..245dd36638c7 100644
@@ -712,8 +712,9 @@ int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask)
 	if (qp->attr.sq_draining) {
 		spin_unlock_bh(&qp->state_lock);
 		cond_resched();
+	} else {
+		spin_unlock_bh(&qp->state_lock);
 	}
-	spin_unlock_bh(&qp->state_lock);
 
 	return 0;
 }
Signature · 1 line
2.37.2
#1 lore raw

Hello,

Quoted 8 lines · Bob Pearson

A recent patch can cause a double spin_unlock_bh() in rxe_qp_to_attr() at line 715 in rxe_qp.c. This patch corrects that behavior.

A newer patch from Guoqing Jiang recommends replacing all spin_lock calls for qp->state_lock to spin_(un)lock_irqsave(restore)() since apparently the blktests test suite can call the kernel verbs APIs while in hard interrupt state. This patch needs to be applied first and Guoqing's patch modified to accommodate this small change.

If you don't mind, I will send a patch set with your patch as first one, then refresh mine. Which means we don't need to keep the second paragraph in commit message, what do you think?

Quoted 13 lines
Fixes f605f26ea196 ("RDMA/rxe: Protect QP state with qp->state_lock")
---
  drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_qp.c +0 -0
index c5451a4488ca..245dd36638c7 100644

drivers/infiniband/sw/rxe/rxe_qp.c int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask) · line 720

Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_qp.c +2 -1
@@ -712,8 +712,9 @@ int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask)
  	if (qp->attr.sq_draining) {
  		spin_unlock_bh(&qp->state_lock);
  		cond_resched();
+	} else {
+		spin_unlock_bh(&qp->state_lock);
  	}
-	spin_unlock_bh(&qp->state_lock);
 
  	return 0;
  }

Looks good, Acked-by: Guoqing Jiang <[email protected]>

Thanks,
Guoqing

#2 lore raw
Quoted 41 lines · Guoqing Jiang

Hello,

Quoted 8 lines · Bob Pearson

A recent patch can cause a double spin_unlock_bh() in rxe_qp_to_attr() at line 715 in rxe_qp.c. This patch corrects that behavior.

A newer patch from Guoqing Jiang recommends replacing all spin_lock calls for qp->state_lock to spin_(un)lock_irqsave(restore)() since apparently the blktests test suite can call the kernel verbs APIs while in hard interrupt state. This patch needs to be applied first and Guoqing's patch modified to accommodate this small change.

If you don't mind, I will send a patch set with your patch as first one, then refresh mine. Which means we don't need to keep the second paragraph in commit message, what do you think?

Quoted 13 lines
Fixes f605f26ea196 ("RDMA/rxe: Protect QP state with qp->state_lock")

---
  drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_qp.c +0 -0
index c5451a4488ca..245dd36638c7 100644

drivers/infiniband/sw/rxe/rxe_qp.c int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask) · line 719

Quoted 9 lines
drivers/infiniband/sw/rxe/rxe_qp.c +2 -1
@@ -712,8 +712,9 @@ int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask)
       if (qp->attr.sq_draining) {
           spin_unlock_bh(&qp->state_lock);
           cond_resched();
+    } else {
+        spin_unlock_bh(&qp->state_lock);
       }
-    spin_unlock_bh(&qp->state_lock);
         return 0;
   }

Looks good, Acked-by: Guoqing Jiang <[email protected]>

Quoted 2 lines

Thanks,
Guoqing

Guoqing,

I don't care how we do it. Perhaps we should leave it up to the maintainers. Just needs to be done.

Bob

maintainer Applied
#3 lore raw
In reply to Bob Pearson
Quoted 9 lines · Bob Pearson

A recent patch can cause a double spin_unlock_bh() in rxe_qp_to_attr() at line 715 in rxe_qp.c. This patch corrects that behavior.

A newer patch from Guoqing Jiang recommends replacing all spin_lock calls for qp->state_lock to spin_(un)lock_irqsave(restore)() since apparently the blktests test suite can call the kernel verbs APIs while in hard interrupt state. This patch needs to be applied first and Guoqing's patch modified to accommodate this small change.

Quoted 7 lines
Fixes f605f26ea196 ("RDMA/rxe: Protect QP state with qp->state_lock")
---
 drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Applied to for-rc, thanks

Jason

#4 lore raw
Quoted 18 lines · Jason Gunthorpe
Quoted 9 lines · Bob Pearson

A recent patch can cause a double spin_unlock_bh() in rxe_qp_to_attr() at line 715 in rxe_qp.c. This patch corrects that behavior.

A newer patch from Guoqing Jiang recommends replacing all spin_lock calls for qp->state_lock to spin_(un)lock_irqsave(restore)() since apparently the blktests test suite can call the kernel verbs APIs while in hard interrupt state. This patch needs to be applied first and Guoqing's patch modified to accommodate this small change.

Quoted 7 lines
Fixes f605f26ea196 ("RDMA/rxe: Protect QP state with qp->state_lock")
---
 drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 3 lines

Applied to for-rc, thanks

Jason

Thanks