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 v2] IB/iser: Fix blocking connect hang and endpoint double free
Date: Tue, 1 Dec 2026 17:26:03 +0200 [thread overview]
Message-ID: <20261201152603.GF31440@unreal> (raw)
In-Reply-To: <20261124090121.77115-1-ziyuzhang201@gmail.com>
On Tue, Nov 24, 2026 at 05:01:21PM +0800, Ziyu Zhang wrote:
> iser_connect() waits for up_completion while holding
> iser_conn->state_mutex. The RDMA CM callback that advances the
> connection state machine needs the same mutex, so a blocking connect
> can never finish establishing and the wait only returns when a signal
> arrives. The caller then sits there with rx_queue_mutex held, which
> stalls the iscsi netlink path for the whole daemon.
>
> Dropping the mutex around the wait is not enough on its own:
> up_completion is only completed on RDMA_CM_EVENT_ESTABLISHED, so an
> address, route, connect or reject error still leaves the waiter asleep
> forever; complete it from iser_connect_error() as well. The cleanup
> events are the other way an attempt can end without an establishment:
> DISCONNECTED, ADDR_CHANGE, TIMEWAIT_EXIT and DEVICE_REMOVAL reach
> iser_cleanup_handler() with the connection still ISER_CONN_PENDING,
> where iser_conn_terminate() does nothing because it only acts on an
> established connection. Terminate a PENDING connection there and wake
> the waiter, leaving the established-connection cleanup unchanged.
> iscsi_iser_ep_poll() must then look at the connection state when the
> completion fires, otherwise a failed attempt is reported as a
> successful connection.
>
> Finally, the failure paths left the connection in ISER_CONN_PENDING or
> ISER_CONN_TERMINATING. iser_conn_release() destroys iser_conn->ep when
> the state is not DOWN, and iscsi_iser_ep_connect() destroys the same
> endpoint again on the error return, so the endpoint was freed twice.
> Terminate the connection and mark it DOWN under the state mutex instead,
> so the endpoint keeps a single owner, and so that no handler can keep
> operating on a connection that is being torn down.
>
> DOWN is terminal: iser_connect() drops state_mutex before the cma_id is
> destroyed, so a late CM error event can still reach iser_connect_error().
> That handler used to move the state to TERMINATING unconditionally, so
> iser_conn_release() destroyed the endpoint first and
> iscsi_iser_ep_connect() destroyed it again when iser_connect() returned.
> Leave a DOWN connection alone there.
>
> Fixes: 504130c039f9 ("IB/iser: Protect iser state machine with a mutex")
> Fixes: 9a3119e4b787 ("IB/iser: Release the iscsi endpoint if ep_disconnect wasn't called")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ziyu Zhang <ziyuzhang201@gmail.com>
>
> ---
> Changes in v2:
> - Wake up the blocking waiter on connection errors and on cleanup events
> received while the connection is PENDING, including device removal.
> - Check the return value of wait_for_completion_interruptible() and
> propagate signal interruption errors.
> - Terminate the connection and set its state to DOWN under state_mutex
> on connect failure, leaving endpoint destruction to the caller.
> - Keep DOWN terminal in iser_connect_error() so a late CM error cannot
> trigger endpoint destruction in iser_conn_release().
> - Check the connection state after a positive completion result in
> iscsi_iser_ep_poll() to distinguish successful and failed connections.
> - Expand the commit message to explain the failure wakeups and endpoint
> cleanup ordering.
>
> v1: https://lore.kernel.org/linux-rdma/20261123144440.65441-1-ziyuzhang201@gmail.com/
>
> drivers/infiniband/ulp/iser/iscsi_iser.c | 11 +++++-
> drivers/infiniband/ulp/iser/iser_verbs.c | 50 +++++++++++++++++++++++-
> 2 files changed, 58 insertions(+), 3 deletions(-)
Sorry, but I’ll have to drop this patch. The commit message is long but
says very little. The code appears to be AI-generated, with no meaningful
human review, and I suspect you don’t have the hardware needed to test it.
Thanks
prev parent reply other threads:[~2026-12-01 15:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 9:01 [PATCH v2] IB/iser: Fix blocking connect hang and endpoint double free Ziyu Zhang
2026-11-24 9:12 ` sashiko-bot
2026-12-01 15:26 ` Leon Romanovsky [this message]
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=20261201152603.GF31440@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