mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Ziyu Zhang <ziyuzhang201@gmail.com>
Cc: sagi@grimberg.me, mgurtovoy@nvidia.com, jgg@ziepe.ca,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	baijiaju1990@gmail.com
Subject: Re: [PATCH] IB/iser: Fix deadlock during blocking connect
Date: Thu, 26 Nov 2026 11:23:56 +0200	[thread overview]
Message-ID: <20261126092356.GF774860@unreal> (raw)
In-Reply-To: <20261123144440.65441-1-ziyuzhang201@gmail.com>

On Mon, Nov 23, 2026 at 10:44:40PM +0800, Ziyu Zhang wrote:
> iser_connect() holds state_mutex while waiting for up_completion. The
> CMA handler for the same connection needs state_mutex before it can call
> iser_connected_handler() and complete up_completion. A blocking connect
> can therefore prevent its own connection completion and leave the waiter
> blocked until a signal arrives.
> 
> Drop state_mutex around the wait and reacquire it before checking the
> connection state, preserving serialization of state and cleanup paths.

You can't randomly drop locks without any explanation why it is safe.

Thanks

> 
> Fixes: 504130c039f9 ("IB/iser: Protect iser state machine with a mutex")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ziyu Zhang <ziyuzhang201@gmail.com>
> ---
>  drivers/infiniband/ulp/iser/iser_verbs.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
> index 55fe68e..9fe2d3f 100644
> --- a/drivers/infiniband/ulp/iser/iser_verbs.c
> +++ b/drivers/infiniband/ulp/iser/iser_verbs.c
> @@ -778,7 +778,9 @@ int iser_connect(struct iser_conn *iser_conn, struct sockaddr *src_addr,
>  	}
>  
>  	if (!non_blocking) {
> +		mutex_unlock(&iser_conn->state_mutex);
>  		wait_for_completion_interruptible(&iser_conn->up_completion);
> +		mutex_lock(&iser_conn->state_mutex);
>  
>  		if (iser_conn->state != ISER_CONN_UP) {
>  			err =  -EIO;
> -- 
> 2.34.1
> 
> 

  reply	other threads:[~2026-11-26  9:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 14:44 Ziyu Zhang
2026-11-26  9:23 ` Leon Romanovsky [this message]
2026-11-26 10:22   ` ziyu zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126092356.GF774860@unreal \
    --to=leon@kernel.org \
    --cc=baijiaju1990@gmail.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mgurtovoy@nvidia.com \
    --cc=sagi@grimberg.me \
    --cc=ziyuzhang201@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®