From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796138767; b=syrONBtX5woe+Yg9j13ynqsCWyuD3gkBc2eBTOnKZ+JkEvg7tqpQ6nyreAxdElnA8Jun YFIdGF9ECJoF6Eh1i+LdnIGtT1UAp/yJs9NldcAzt2uuzYE55PQWyCIsaVf+2G6Q/FDvG mDNDPaPxi0+kS0jeU6ddII6LUXFkK2ct4lr9hKjhAHD9vxwkAI8P8dTH0gAFf3d2dGXIc g7wL2O+x6GdluAZVVbQgDDaHeCHBJGygQ97YMrJArKRUDL5vsG4NZkTxLh2XbkXD5maIN kydyYDHRkCOBk16oZ95PYyErtpycNRVAUJZFRdzqZ0o0RANXwpKYCO40JUWodE1s0Tg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796138767; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=vxyrPnGJYo2/uRZUuIlob5dPhu8zTFU0TwhT9numrYs=; b=GTFYd+Dm710h5nllRq2Ei7UuX9n3oriSDNefbeI38ZcsBF/WsICHV8xEZcR3pNP/YUkc cNipnv6sWykdlPMGNAET2zoUIw7sPD1LmRE/hsMJ+zzdJ5tavbFqScAo6CyRySWmCwSaI cqPpjXr32UrqKm7CDcmWVV9SPVoKKQpSy3Aq7mvvykNWg0MftsxXJjcEw2b0t5DqyWw5r 3gxx89+DVVbOqqeH+fi5D9JZu98Pe/fMRyn9JbvwD9d4dOxOuEOUXDt9NbUzvGO8TVwfa VKOeN3WAODxgv62z2fPhHM5aDlFxYTuBk9eTPgbWRF0xAk5dj6qS0K2JnnybrxVW+kw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BbQkBRoA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C77AC606A31A; Tue, 1 Dec 2026 15:26:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BbQkBRoA Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4A461F00893; Tue, 1 Dec 2026 15:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796138767; bh=vxyrPnGJYo2/uRZUuIlob5dPhu8zTFU0TwhT9numrYs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=BbQkBRoA1+oct8rBZKcHIGYqmVHgwGozcH31sC4cEKR+nlYw7V2dwT6eP1fhjPnTl mYOIhG4dDPDx4Fol3gvrutDr6CFlJW810ZBB9TLMiqiTaYXtzNDWy/0BX10bqwwYbm XLPFcU6U8QDSpfOhWtySZoOvoA0PrqjYCxDDbPcHgSriIzeTL7gcM4BQi1KA0BF9W8 EOQgSKNCkP5OxOHGwTZ3hGl2PxH9ZZBrpA9p49eFk7/6wq1f1+ST8he6abDwNQFEok yOua7lpBTakQizhaunwToV30XJU9IHi86uyCncY/D1aGe1I8s8b+wFuAsBsPOx0YTI M+Y7Z6Btigq0Q== Date: Tue, 1 Dec 2026 17:26:03 +0200 From: Leon Romanovsky To: Ziyu Zhang 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 Message-ID: <20261201152603.GF31440@unreal> References: <20261124090121.77115-1-ziyuzhang201@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 > > --- > 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