linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix a deadlock in the ib_srp driver
@ 2022-02-15 21:05 Bart Van Assche
  2022-02-15 21:05 ` [PATCH v2 1/2] ib_srp: Add more documentation Bart Van Assche
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Bart Van Assche @ 2022-02-15 21:05 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Leon Romanovsky, linux-rdma, Tetsuo Handa, Bart Van Assche

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


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

* [PATCH v2 1/2] ib_srp: Add more documentation
  2022-02-15 21:05 [PATCH v2 0/2] Fix a deadlock in the ib_srp driver Bart Van Assche
@ 2022-02-15 21:05 ` Bart Van Assche
  2022-02-15 21:05 ` [PATCH v2 2/2] ib_srp: Fix a deadlock Bart Van Assche
  2022-02-23 19:14 ` [PATCH v2 0/2] Fix a deadlock in the ib_srp driver Jason Gunthorpe
  2 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2022-02-15 21:05 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Leon Romanovsky, linux-rdma, Tetsuo Handa, Bart Van Assche

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

Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/ulp/srp/ib_srp.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index abccddeea1e3..55a575e2cace 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -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.
  */

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

* [PATCH v2 2/2] ib_srp: Fix a deadlock
  2022-02-15 21:05 [PATCH v2 0/2] Fix a deadlock in the ib_srp driver Bart Van Assche
  2022-02-15 21:05 ` [PATCH v2 1/2] ib_srp: Add more documentation Bart Van Assche
@ 2022-02-15 21:05 ` Bart Van Assche
  2022-02-16  7:04   ` Leon Romanovsky
  2022-02-23 19:14 ` [PATCH v2 0/2] Fix a deadlock in the ib_srp driver Jason Gunthorpe
  2 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2022-02-15 21:05 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Leon Romanovsky, linux-rdma, Tetsuo Handa, Bart Van Assche,
	syzbot+831661966588c802aae9

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 <penguin-kernel@i-love.sakura.ne.jp>
Fixes: ef6c49d87c34 ("IB/srp: Eliminate state SRP_TARGET_DEAD")
Reported-by: syzbot+831661966588c802aae9@syzkaller.appspotmail.com
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index e174e853f8a4..285b766e4e70 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -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);

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

* Re: [PATCH v2 2/2] ib_srp: Fix a deadlock
  2022-02-15 21:05 ` [PATCH v2 2/2] ib_srp: Fix a deadlock Bart Van Assche
@ 2022-02-16  7:04   ` Leon Romanovsky
  0 siblings, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2022-02-16  7:04 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Jason Gunthorpe, linux-rdma, Tetsuo Handa, syzbot+831661966588c802aae9

On Tue, Feb 15, 2022 at 01:05:11PM -0800, Bart Van Assche wrote:
> 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 <penguin-kernel@i-love.sakura.ne.jp>
> Fixes: ef6c49d87c34 ("IB/srp: Eliminate state SRP_TARGET_DEAD")
> Reported-by: syzbot+831661966588c802aae9@syzkaller.appspotmail.com
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/infiniband/ulp/srp/ib_srp.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

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

* Re: [PATCH v2 0/2] Fix a deadlock in the ib_srp driver
  2022-02-15 21:05 [PATCH v2 0/2] Fix a deadlock in the ib_srp driver Bart Van Assche
  2022-02-15 21:05 ` [PATCH v2 1/2] ib_srp: Add more documentation Bart Van Assche
  2022-02-15 21:05 ` [PATCH v2 2/2] ib_srp: Fix a deadlock Bart Van Assche
@ 2022-02-23 19:14 ` Jason Gunthorpe
  2 siblings, 0 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2022-02-23 19:14 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Leon Romanovsky, linux-rdma, Tetsuo Handa

On Tue, Feb 15, 2022 at 01:05:09PM -0800, Bart Van Assche wrote:
> Bart Van Assche (2):
>   ib_srp: Add more documentation

Applied to for-next

>   ib_srp: Fix a deadlock

Applied to for-rc

Jason

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

end of thread, other threads:[~2022-02-23 19:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 21:05 [PATCH v2 0/2] Fix a deadlock in the ib_srp driver Bart Van Assche
2022-02-15 21:05 ` [PATCH v2 1/2] ib_srp: Add more documentation Bart Van Assche
2022-02-15 21:05 ` [PATCH v2 2/2] ib_srp: Fix a deadlock Bart Van Assche
2022-02-16  7:04   ` Leon Romanovsky
2022-02-23 19:14 ` [PATCH v2 0/2] Fix a deadlock in the ib_srp driver Jason Gunthorpe

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