Fix a deadlock in the ib_srp driver
Subsystems (2)
Bart Van Assche
maintainerv2 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(-)
Bart Van Assche
maintainerPATCH 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
@@ -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. */
Bart Van Assche
maintainerPATCH v2 2/2 ib_srp: Fix a deadlock
In reply to Bart Van AsscheRemove the flush_workqueue(system_long_wq) call since flushing system_long_wq is deadlock-prone and since that call is redundant.
--- drivers/infiniband/ulp/srp/ib_srp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +4 -2
@@ -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);
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 flushingsystem_long_wqis 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]Signed-off-by Bart Van Assche <[email protected]>--- drivers/infiniband/ulp/srp/ib_srp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Thanks,
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