Re: [PATCH v2] IB/iser: Fix blocking connect hang and endpoint double free

From: Leon Romanovsky

Date: Tue Dec 01 2026 - 10:26:15 EST


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@xxxxxxxxxxxxxxx
> Signed-off-by: Ziyu Zhang <ziyuzhang201@xxxxxxxxx>
>
> ---
> 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@xxxxxxxxx/
>
> 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