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=1796199107; b=dClrJ9kNoSM2T0BetzKzNYcx8tQd8DF8IqYUXlU4/geqW2pbBXp9/9FMB/49r7t0Yt7K PIHkqR1CXwmGh5WWbu/6IqKDmHtOXebaf+b26TCa6jEJvi/ci0LxbAl8XBtldw0m6nCrh 0p79uPtQnUquaHfqhWG2JZDc/P66sGKPp2YleJ4IDpT2vUHdmJvyjL1TRWqsd4DC7kfvd TRFmgv65cETVrwBSHc9Icr5NPM1dIivyYPxxjBaZaSMMCjIwQRK8F2S8+3lEufBs44hEW m74BgP7BsFFENphzFqoxBZ+FHH3c+qjV2c/RKDQNcM82mrars9z26SHRniDtuPtvnVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796199107; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=m1Rz4CvUrfGqzFO0TyJl9sKquz8GTYfS6ooFLY9+M94=; b=pRuHLn7IlgdmSdvljr3B0xTBUMYB9rLf18XVw0H2BQtlr6rkCHa/WhBxLbVX3Sdmza/L t4ORho6632qhk6nclakt04zsrZpAMisLY0tEi3AO0VGsxAqfGlYETm9yEh+7/P59685hW +yQc8sR7Sbnz65cVB2jHA2PgKXMzn0Z9yi9XR3wd+hsusJVbxNJHEc/3EIq79cvDeg7xo 66jRLNNARik33wrJ0GwSl3DgFGxz/6YkVQnHoHAEkONMjSN4Y7b5cd/xTU3Xazvcj+waS gZgZeXyxy8P+okpPthqeBwypHmNDr3qZgdoysznqlHoQtjZ2QMaT1kA8PfiQKN+42eQ== 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="aV2D/70h"; 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 BF2E0606A31A; Wed, 2 Dec 2026 08:11:47 +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=aV2D/70h Received: by smtp.kernel.org (Postfix) with ESMTPSA id C79351F000C1; Wed, 2 Dec 2026 08:11:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796199107; bh=m1Rz4CvUrfGqzFO0TyJl9sKquz8GTYfS6ooFLY9+M94=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=aV2D/70hkPyTFgRr7BlC39WsnJV3nW1zu5UfSHT5eDCuyU2hDbhIYddxnvf7VVRUo VQnUDYHGxkELVEUOfwIEHhXg0JCc47E+wm34JKishD/bHbzJ+K0uW5x1K4B3KhwC8u V8jJRo7EXQxl5Ek00SXkW45Ena4iO5SwSTWE4BzYTIZ74sDdaU+MliMCvh1dyP5+Ck ffuUU1pbhyVANoJ4CEUH3AJvqxixbsxktWRuPfwlzy01Eo7gH9xc8qW/dRvAHTIX9h 7ML7O3ClliH5HGj+cZl6tSylMsH8hjzbLBvb2sxF17Y/n8PWMu5mbBxXEZNBB8ZBIS nm0Y8s3f6ciVA== Date: Wed, 2 Dec 2026 10:11:43 +0200 From: Leon Romanovsky To: Andrew Stellman Cc: Jason Gunthorpe , Bernard Metzler , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 rdma-rc] RDMA/iwcm: Handle CLOSE before passive establishment Message-ID: <20261202081143.GI31440@unreal> References: <20261129135257.80754-1-bugs@stellman-greene.com> <20261130044601.28226-1-bugs@stellman-greene.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=us-ascii Content-Disposition: inline In-Reply-To: <20261130044601.28226-1-bugs@stellman-greene.com> On Sun, Nov 29, 2026 at 11:46:01PM -0500, Andrew Stellman wrote: > From: Andrew Stellman > > An accepted siw MPA v2 connection enters RDMA mode before receiving the > peer's RTR frame. If the peer sends a malformed RTR frame, siw reports > CLOSE while the passive IWCM ID is still in CONN_RECV. > cm_close_handler() treats that state as impossible and hits BUG(): > > kernel BUG at drivers/infiniband/core/iwcm.c:966! > Internal error: Oops - BUG: 00000000f2000800 [#1] SMP > Workqueue: iw_cm_wq cm_work_handler > pc : cm_work_handler+0xf40/0x1098 > Call trace: > cm_work_handler+0xf40/0x1098 (P) > process_one_work+0x5f0/0xcb8 > worker_thread+0x3ac/0xaa0 > kthread+0x36c/0x420 > ret_from_fork+0x10/0x20 > > The fix belongs in the IWCM core rather than siw, because siw can't > report this as ESTABLISHED with an error status: cm_conn_est_handler() > moves CONN_RECV to ESTABLISHED regardless of status, and the CMA turns > it into RDMA_CM_EVENT_ESTABLISHED. > > Handle CLOSE in CONN_RECV as a failed passive connection. Move the ID to > IDLE, clear the connect wait flag, notify the consumer with > -ECONNRESET if the provider gave status zero, and wake waiters. The > existing exit path drops the QP reference. The consumer now gets a > disconnect event for this case instead of the BUG(). > > If the peer sends its RTR frame and then FIN, siw can queue CLOSE before > ESTABLISHED. ESTABLISHED then finds the ID in IDLE, or in DESTROYING if > the consumer destroyed the ID after the disconnect event while the > ESTABLISHED work item had already passed the IWCM_F_DROP_EVENTS check. > Either way it would hit the BUG_ON() in cm_conn_est_handler(), so ignore > ESTABLISHED in IDLE and DESTROYING. ESTABLISHED in CONN_RECV is handled > as before. > > Tested in QEMU (arm64) on mainline 7.4.0-rc4 with KASAN. A peer > running as uid 1000 with no capabilities that sent a malformed RTR > frame hit the BUG() without the patch. With the patch, the server got > RDMA_CM_EVENT_DISCONNECTED with status -104 and no BUG(). With the > patch, a valid RTR connection got ESTABLISHED then DISCONNECTED, and > rping completed three exchanges. > > The two ESTABLISHED orderings only occurred with test-only delays: 50 ms > after siw queues PEER_CLOSE and 100 ms after its CLOSE upcall, 500 ms in > IWCM after the drop check, and 100 ms in the consumer before destroy. > With the siw delays, a peer that sent a zero-length RTR frame and then > shut down its socket hit the BUG_ON() with the first version of this > patch. With all four delays, the second version hit it in the > DESTROYING case. With this version, the server got > RDMA_CM_EVENT_DISCONNECTED with status -104, destroyed the ID, and > there was no BUG. Without the delays, one run each of the second and > this version got ESTABLISHED before CLOSE. > > The issue was found by OpenAI GPT-6 (Codex) while reproducing another > siw bug. The fix was drafted with OpenAI GPT-6 (Codex) and this > changelog with Claude Sonnet 5.5, and both were reviewed by me. > > Fixes: 6c52fdc244b5 ("rdma/siw: connection management") > Signed-off-by: Andrew Stellman > --- > v3: Also ignore ESTABLISHED when a concurrent destroy has moved the ID > from IDLE to DESTROYING. Sashiko reported this race in its review > of v2: > https://lore.kernel.org/linux-rdma/20261129135257.80754-1-bugs@stellman-greene.com/ > The changelog now describes the whole patch. > > v1: https://lore.kernel.org/linux-rdma/20261129001745.78689-1-bugs@stellman-greene.com/ > > Tested at mainline ca20d5a011d3 (7.4.0-rc4), except that the unpatched > malformed-RTR BUG() and the RTR-then-FIN BUG_ON() with the first version > were run at f93eb7cfc4bf (7.4.0-rc4). > > A reproducer is available on request. > > drivers/infiniband/core/iwcm.c | 26 +++++++++++++++++++++++--- > 1 file changed, 23 insertions(+), 3 deletions(-) You have submitted enough patches that I expect a higher standard. First, do not send revised patches as replies to the previous version. Second, include the full stack trace rather than a truncated report. Third, write a meaningful commit message that clearly explains what is broken and why the change is needed, instead of AI-generated text. Thanks