Re: [PATCH 1/3] iscsi-target: Fix potential deadlock on lock taken in timer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2012-11-05 at 18:02 -0800, Roland Dreier wrote:
> From: Roland Dreier <roland@xxxxxxxxxxxxxxx>
> 
> We need to disable BHs when taking sess_idr_lock because the
> iscsit_handle_time2retain_timeout() timer function takes
> se_tpg->session_lock, and iscsit_close_session() nests sess_idr_lock
> inside se_tpg->session_lock.  So if the timer can run inside
> sess_idr_lock, we have a potential AB-BA deadlock.
> 
> Fix this by disabling BHs when taking sess_idr_lock.  This was found
> because of a lockdep warning, but it looks like a real (if highly
> theoretical) deadlock.  In any case avoiding lockdep spew so that we can
> find other issues is a worthy cause.
> 
> Signed-off-by: Roland Dreier <roland@xxxxxxxxxxxxxxx>
> ---
>  drivers/target/iscsi/iscsi_target_login.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
> index f8dbec0..3f34ecf 100644
> --- a/drivers/target/iscsi/iscsi_target_login.c
> +++ b/drivers/target/iscsi/iscsi_target_login.c
> @@ -254,9 +254,9 @@ static int iscsi_login_zero_tsih_s1(
>  		kfree(sess);
>  		return -ENOMEM;
>  	}
> -	spin_lock(&sess_idr_lock);
> +	spin_lock_bh(&sess_idr_lock);
>  	ret = idr_get_new(&sess_idr, NULL, &sess->session_index);
> -	spin_unlock(&sess_idr_lock);
> +	spin_unlock_bh(&sess_idr_lock);
>  
>  	if (ret < 0) {
>  		pr_err("idr_get_new() for sess_idr failed\n");

Looks fine, and applied to for-next.

Thanks Roland!

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux