Skip to contentSkip to conversation

Fix a deadlock in the ib_srp driver

PATCH Applied Bart Van Assche 3 participants 5 messages Feb 15, 2022 – Feb 23, 2022

Subsystems (2)
lore
Share & tools
lore

Bart Van Assche

author maintainer
#0 lore raw

v2 cover Fix a deadlock in the ib_srp driver

Hi Jason,

This patch series fixes a deadlock in the ib_srp driver that was discovered by syzbot. Please consider these patches for kernel v5.18.

Thanks,

Bart.

Changes compared to v1:
- Dropped patch 2/3, the patch that converts a spinlock into a mutex.
- Simplified patch 3/3 by removing a flush_work() loop.

Bart Van Assche (2):
ib_srp: Add more documentation
ib_srp: Fix a deadlock

 drivers/infiniband/ulp/srp/ib_srp.c |  6 ++++--
 drivers/infiniband/ulp/srp/ib_srp.h | 11 ++++++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
author maintainer
#1 lore raw

PATCH v2 1/2 ib_srp: Add more documentation

Make it more clear what the different ib_srp data structures represent.

---
 drivers/infiniband/ulp/srp/ib_srp.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/srp/ib_srp.h +10 -1
index abccddeea1e3..55a575e2cace 100644
@@ -92,6 +92,9 @@ enum srp_iu_type {
 };
 
 /*
+ * RDMA adapter in the initiator system.
+ *
+ * @dev_list: List of RDMA ports associated with this RDMA adapter (srp_host).
  * @mr_page_mask: HCA memory registration page mask.
  * @mr_page_size: HCA memory registration page size.
  * @mr_max_size: Maximum size in bytes of a single FR registration request.
@@ -109,6 +112,12 @@ struct srp_device {
 	bool			use_fast_reg;
 };
 
+/*
+ * One port of an RDMA adapter in the initiator system.
+ *
+ * @target_list: List of connected target ports (struct srp_target_port).
+ * @target_lock: Protects @target_list.
+ */
 struct srp_host {
 	struct srp_device      *srp_dev;
 	u8			port;
@@ -183,7 +192,7 @@ struct srp_rdma_ch {
 };
 
 /**
- * struct srp_target_port
+ * struct srp_target_port - RDMA port in the SRP target system
  * @comp_vector: Completion vector used by the first RDMA channel created for
  *   this target port.
  */
author maintainer
#2 lore raw

PATCH v2 2/2 ib_srp: Fix a deadlock

In reply to Bart Van Assche

Remove the flush_workqueue(system_long_wq) call since flushing system_long_wq is deadlock-prone and since that call is redundant.

Cc Tetsuo Handa <[email protected]>
Fixes ef6c49d87c34 ("IB/srp: Eliminate state SRP_TARGET_DEAD")
Reported-by [email protected]
---
 drivers/infiniband/ulp/srp/ib_srp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +4 -2
index e174e853f8a4..285b766e4e70 100644
@@ -4047,9 +4047,11 @@ static void srp_remove_one(struct ib_device *device, void *client_data)
 		spin_unlock(&host->target_lock);
 
 		/*
-		 * Wait for tl_err and target port removal tasks.
+		 * srp_queue_remove_work() queues a call to
+		 * srp_remove_target(). The latter function cancels
+		 * target->tl_err_work so waiting for the remove works to
+		 * finish is sufficient.
 		 */
-		flush_workqueue(system_long_wq);
 		flush_workqueue(srp_remove_wq);
 
 		kfree(host);
maintainer Reviewed-by on v2 2/2
#3 lore raw

Re: [PATCH v2 2/2] ib_srp: Fix a deadlock

Quoted 11 lines · Bart Van Assche

Remove the flush_workqueue(system_long_wq) call since flushing system_long_wq is deadlock-prone and since that call is redundant.

Cc Tetsuo Handa <[email protected]>
Fixes ef6c49d87c34 ("IB/srp: Eliminate state SRP_TARGET_DEAD")
Reported-by [email protected]
---
 drivers/infiniband/ulp/srp/ib_srp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Thanks,

maintainer Applied
#4 lore raw
In reply to Bart Van Assche
Quoted 2 lines · Bart Van Assche

Bart Van Assche (2):
ib_srp: Add more documentation

Applied to for-next

Quoted 1 line

ib_srp: Fix a deadlock

Applied to for-rc

Jason