From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796111928; b=4NvKxd5lxMmwZgwSfpLu0mGpz09CgqCUStsq6StjXNCBfoT+W+jR4l+sb5nD6e8jg10O /yeCqQifzXxvOTnlWiDGVajMjMNQoNA9D38kNpf7Hsu3ZuVOG4ftT3GzNhF1I9ye1Xmyn GBzh4Zwqhr56/RZqzocP4AaXVbg55XK259sI7BahPr4OxBxWZWsZ5WkEJ5wMCbpZ9VNUi j7C9OHMEk//TdyT9WhvVWeLv8oTs5ZN/UDm8QbJUl4VZ+bDZzsLUIvKkmfBdYY3PnAVgG 6eNOW1B++ifYkGWG9VyFz6wxl2VHhgxHlEKrDQ5Jn/l4HLvqLq+qa/OqEEHSzi80DBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796111928; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-TM-AS-GCONF:X-Proofpoint-Reinject:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Spam-Info: X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=4Kq9gp++LfbZmlIQp/6LCiw3gj3ITBrevfOCz7rR9G4=; b=b0C1cmPzMENcZ6UonB7hhEyv6NBsaRbxWWbEkyNmudjLdogQLsbcDQkd4jgQmk8ohD86 c1diNfDqMnvOkqX7EL9Xrwue5DVQOK+PiA7fZi3FC9O0mOXClP11vPByFaePFdyt8XXjp O0BOqpyM3KK2d6CpNJGh6BmUFfxXVFAyHZ8lBixrfqIj25a28gOmPBZvS6nqI7YtxHxKx JW0+TghWssJnrQLZX+71zveRs99MwckpWDB0SdAbm2MYXy81YcDalTXrc0f6VsI2ImuF6 eHlOsnsfXjw7/qLYuhpYIGzYKquzK969epQ5WThfSLAca3wIwlVEAE8vfKSn8AoFbbg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=YqDNJO9B; arc=none smtp.remote-ip=148.163.158.5 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BDB1606A31A; Tue, 1 Dec 2026 07:58:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9BDB1606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=YqDNJO9B Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B12Z1l8640314; Tue, 1 Dec 2026 07:58:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=4Kq9gp++LfbZmlIQp/6LCiw3gj3ITBrevfOCz7rR9 G4=; b=YqDNJO9BgEJyhwi5EyBYznUZDFyuKX5WaJ/fSVvLiGIy22bocnn9FldLI AYG+5JIzYfm11w6ltbBAxmJOwgW5/eaBKPbGJwmhKIfy3Tigcogo3LP1YNTu1NmX 77kJZZ1UH4H4xOQgB+QaFHTqrBEmbF7/Bw83V4FTfTjbuKAIlsAuUeOShP1jQUSc NWYpfW4HYoYxZjRTKY1dw0PTfJFz5K2hasDciP2TzGnbL1EIMRmYHrRVO0mr3jT5 wNkbhz3HBbUm5gKP1HN5zJ++pJErnjDpXor/MUbxkCL9WV3irDNKjAh4AZLbtETp 5VQHANeOMOe5ulSLllZrrJsa0WLzA== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pku33fr-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 07:58:32 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B17qagD3950095; Tue, 1 Dec 2026 07:58:31 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4j8bggg3pm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 07:58:31 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B17wRcw49283330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Dec 2026 07:58:27 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 822982004D; Tue, 1 Dec 2026 07:58:27 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E2D92004B; Tue, 1 Dec 2026 07:58:27 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with SMTP; Tue, 1 Dec 2026 07:58:27 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 56341) id 359F316086E; Tue, 01 Dec 2026 08:58:27 +0100 (CET) From: Mahanta Jambigi To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, alibuda@linux.alibaba.com, dust.li@linux.alibaba.com, sidraya@linux.ibm.com Cc: hidayath@linux.ibm.com, pasic@linux.ibm.com, horms@kernel.org, tonylu@linux.alibaba.com, guwen@linux.alibaba.com, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-rdma@vger.kernel.org, Mahanta Jambigi Subject: [PATCH net-next v3 0/3] net/smc: fix clcsock lifetime vs asynchronous paths Date: Tue, 1 Dec 2026 08:58:12 +0100 Message-ID: <20261201075815.2159547-1-mjambigi@linux.ibm.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=KZZHIgYD c=1 sm=1 tr=0 ts=6b0e7e28 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=e0kRlRqOptjlawYriWYA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDAzMCBTYWx0ZWRfXyeDIoKSswrPW EsCIxareKHldF3xd7x/Wuvch7H8yHX433pJZ5CLMY02zO6yl1AvItCpZhNHSUdSfX+bhgdv/TvJ 5wlB9huPCzEyJy+Lj8YnqEbP32bu9gN1MdbAhqASv44xqLe0jtIOZ3Hvn8lLJXpUFvIrWmQV/FO k+ChZ+b3amwpGL/ii+fXLk+N4E3cg09MJb3F5Irb8X1K4bumpxIsmeNoFdtllp7Lvki8OctatbU vTO0WDViCLSXkDjCQ3NfIYUWbMeYowL/sOZQ3TzgmZ5pxb9089UB38BmJQ2ChliwIEX4a/n9X+/ A3bp69ULq1k7LjdSqEPIc7RY1yo+IXBXbvSq/3hHLTNPojGNZRd3mQr8Ok2Gccn5WzpNtNQGMkQ SEn6EYNhWwams0mYlln9Ow50aD+5QaX/Ubqo5CCBINvJhoELh8qU8P73sFguwtlXUDPG1UdikMm PS+DWcW5CfYtWkHXHIw== X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDAzMCBTYWx0ZWRfX7wzVzCB58QEy l2/IK1mCaT7RQDN2OEjH2DUvusPr5qDYphu9rFz9lhzk3kMALjidy2K1VkXUi4gtrku1jWTkVUI ywZ4M302ectM+iLBuqZKv48XbmRhaiY= X-Proofpoint-ORIG-GUID: j57mNJ2Ofo520ql3pohdIV2Ydq4b3EGu X-Proofpoint-GUID: Y6gdwnlPDpdfhkhrXW6n2K_OVMiMus7E X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_01,2026-11-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010030 The internal TCP socket (clcsock) of an SMC socket is freed by asynchronous paths: link group termination reaches smc_close_active_abort() and peer close reaches smc_close_passive_work(), and both can run while the SMC socket is still referenced by an open file descriptor. A task that uses the fd at that moment, for example getsockopt() or a socket diag dump, then operates on a released socket. Free the clcsock only when no socket file can reference it: from the socket release paths, after the socket has been unhashed, and from the abnormal close paths once the socket has no file left. The decision is made under the socket lock, and the accept path holds the same lock across the accept-queue state check and sock_graft(), so a connection that is being accepted cannot lose its clcsock to an asynchronous close. The clcsock_release_lock is no longer needed: a socket operation on a file is serialized with smc_release() by the file reference, and the listen work is covered by flush_work() and cancel_work_sync() in smc_clcsock_release(). Trade-off: with an open file, a clcsock now stays allocated after an abnormal close until the application closes the SMC fd. The SMC connection is already torn down and its TCP connection has been reset or shut down; only the local TCP socket remains allocated until then. Patch 1 makes the lifetime change and is self-contained. Patch 2 removes the lock and the checks it made necessary, and serializes the accept path with the asynchronous close. Patch 3 documents the invariant and adds a destructor warning for it. The diag dump keeps its NULL check: a socket is hashed in smc_sk_init(), before its clcsock is created. This is hardening found by code walk, not a fix for a reported regression, so the series targets net-next and carries no Fixes: tag. --- Changes in v3: - Rebased onto net-next d7f7fac1c. No code change; the diff is unchanged apart from hunk context, and the series applies cleanly with git am. Changes in v2: - Rebased onto net-next (eb6d6c80d354) instead of the torvalds tree (7e1392a42ea2). The patch content is unchanged; the only differences are unrelated net-next context: patch 2 now shows the READ_ONCE() around limit_smc_hs, and hunk labels were re-derived. - Patch 1: clarify the commit message to say the issue was found by code inspection rather than from a reported regression, and to describe the conn->freed rationale more precisely. - No functional change to the series. Mahanta Jambigi (3): net/smc: keep clcsock until socket release net/smc: remove the clcsock release lock net/smc: document the clcsock lifetime net/smc/af_smc.c | 123 +++++++++++++++++--------------------------- net/smc/smc.h | 8 ++- net/smc/smc_close.c | 35 +++++++++---- net/smc/smc_diag.c | 3 ++ net/smc/smc_inet.c | 9 ++-- 5 files changed, 82 insertions(+), 96 deletions(-) base-commit: d7f7fac1c3220a430559c6d43904e27917ae1eb0 --=20 2.50.1 (Apple Git-155)