From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796112069; b=F7y/u6JaiZI/Ea/bNZLzOe7lW/cZzLbAwBgNddEQKlsGOdHoFuNy9ylsiwKDvziqxRhx jed/+SsaUTm/uO+9Fs7zm0JpxBywrtxdCjhYBFtmlLn3yxwR1Ew8vNoYOc8ggkEJCjPMJ V2hfaNVrGbSkARe5aG42Z600/pEjig3b4APakOMMXuIkmZ3VlGX+uUXiayCsl0etm8jUN oj83IONWuVvJ+qXhXnahM6vAtJyoNwva34qel9oCU0Rz/8omDxbcGuaRxA6ulLQwtwPi7 201ANx68LDpjUFrhqMfsg9UHpTxg4ztYbBmOab6DijvjhkOmdNiwetQqd/2+0VcC+SA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796112069; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-TM-AS-GCONF: X-Proofpoint-Reinject:X-Proofpoint-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=Bd3c4GmlXfjm5xDb3J5IsGj7DO8x2rhcUNbz007bSGo=; b=LlvSGqQ9IciOmWNcEpXO+a0rpGk0jK9YH8rKv1IIg9C6IwjFXtaNFFq8H7mNLBodgXVH zZAxgsFWRzK+iU5Q8SOVWRskHHIGMsKeUENvB7wjTSo4fQ+CcgeBGdKkIACV3z/spb6cj +sWe+NjqZKo4b4tdIMP0wW3m+3AoqEoSbz/KtaIAq1v1A2eWBsOjDeOJi3Wd5GiEmU3LD H0m0E8icaB4LkVlYH55B9qamlRdH+tYYKRc5aKRDqb1XZ/ovwbXgdLYVsheQrmnRs3yHO O5g2jJA1KaAPGz02MxA+kD1kOWapVmizSid2+J1aPDV3JBU0XgUMebQUczq9p/LKu6Q== 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=npVmFU8l; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 D4AB8606A31A; Tue, 1 Dec 2026 08:01:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D4AB8606A31A 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) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=npVmFU8l Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B12Zt9a645951; Tue, 1 Dec 2026 08:01:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=Bd3c4G mlXfjm5xDb3J5IsGj7DO8x2rhcUNbz007bSGo=; b=npVmFU8lGm8iU4t0ky8MP9 CLdd54b6trkGsBE3+U2Xm38xoDw7zj4L0GpkFIboenteYNeDI4T+KKAlzl1Fxrel D8OiOkDr9nUbHPXomJcWLg0UaQHEjISpGT9LH6eg3KTNUeBoXmgeWEh+7C/oMkvR WO+9FnMw5NqROZl98TYpfVjKLil7ouFuvQvA8cn7XJvXczepVy0NiE9Al9MQNt4s 7B4vvfkYT/pq0UMSAu6XEcD2Mut+9lndwO5QeJ7cMO5PrTSQB887m7JcsyBvpITR MY9W7toLMH8fH0OMMsWNp8E7a3v1qKravaYzqQV036ejHsr19meVBT9y8LjmYK8A == Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pp5unky-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 08:01:02 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B17YuLg2305735; Tue, 1 Dec 2026 08:01:01 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j8a9k0aga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 08:01:01 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B180xqi24576540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Dec 2026 08:01:00 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABAB55805E; Tue, 1 Dec 2026 08:00:59 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D092758050; Tue, 1 Dec 2026 08:00:52 +0000 (GMT) Received: from [9.123.8.233] (unknown [9.123.8.233]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 1 Dec 2026 08:00:52 +0000 (GMT) Message-ID: Date: Tue, 1 Dec 2026 13:30:51 +0530 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v2 0/3] net/smc: fix clcsock lifetime vs asynchronous paths To: willemb@google.com, 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 References: <20261124074927.3622245-1-mjambigi@linux.ibm.com> Content-Language: en-US From: Mahanta Jambigi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: _OJFobRMFT5WEoXXQ4rnhq8NPQzhp6-r X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDAzMCBTYWx0ZWRfXzVdI4/ax0q1n Hzg7450v2fmjxS68s1cFZ5mb1j7+JNDsCPd20uimAouYa7qOMXeyhJGk0zrzjDJ0DiHwX3tVW4Z c8ROgEeEyoBF9PDFHrwMk387yMGrHjI= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDAzMCBTYWx0ZWRfX3sVL8GzJM/P5 i9EGTgRqYsJRONlB8dQp/qEDXHLZjHmJU4rOdVJM02kLIwH1PlCsqVoBqlHDbSea+W68tYySLnT +CpO0LvUwtOHldYftPH/SNpdZiseQePSTmcOMwfmDcRy+aEDoQ8P1JQ7KXv3bed/HBYaxEpTPbd FaMncJdbtafXluQOABH8iYYwHG3SXUH7Q7U1aWUnEmh57N6RU4oh+Kw6R5/qUVo0oghUFX0HOO3 eftbNWeD8xNNtwOKapNqSgQYG3qx/Rm9ndeE6WpICryYKZMhP3iCsvsQ5Yoj35xIm552ovnKOUr L5fuiDbS1cyTc9gJpZAHZkfThg4yCnqOG0HBEgH62V1a8IB91hEshHaijwzJehOhCjt2GTK3/xN uBOT9kVZ6lJzkCPSXiGOvXNIx3YN2eozBingTDrofcmKsUQ09mscuJLBQaXRXTRIYwLxBcTJW87 ONLE2vc0zwGWTSxc+dg== X-Authority-Analysis: v=2.4 cv=Ae8kjHXG c=1 sm=1 tr=0 ts=6b0e7ebe cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=1XWaLZrsAAAA:8 a=GBLbv43cW-JElwczKWoA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: voKi8F4TizUICisS8XDzc1gXGAHl605u 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 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010030 On 29/11/26 8:21 pm, willemb@google.com wrote: > Mahanta Jambigi wrote: >> 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 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: eb6d6c80d35449c27471b1874f13066c09a8964d > > This series no longer applies cleanly to current net-next (conflict in > net/smc/af_smc.c reported by NIPA contest). Please rebase onto current > net-next and repost v3. v3 has been posted, re-based onto net-next *d7f7fac1c*. It applies cleanly there (checked with git am) and builds with no warnings, producing smc.ko and smc_diag.ko.