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=1796282462; b=BafBPIyOB13t6jBu2IiddEw7ua2mmo6R6HX+lhnZyULmiHD82uoBIes2iDf5DPInejJH numW4XRBU49tsKfTjue421caiSE6tq9qhvHC6e2MPWjcik1oaOrz1O23DHaN5v9WFuJXr O+8w4zQXMbdF8fiBlYqU6V5m/UDb6cB8mbyJeDDxOtrIRQrkwZ6rPf6J5AtZJoX3+pn+i ECir9TdR7jPRLxS2l8W/wCN/7pI+zk+ccxt9O2Fu1aSPj03IDCH4gf2rzpmwQN5Tos/Dc +U+giBdOqRM4SuPnOxXFaSO/15fIsWkfNp5vEshokqzh3LKYrDnNrMq0nOFbLvwb2+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796282462; 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-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=/S0wX/Ix6lduOp3lBfTiH/yUzhQltEk0lIk/QS6DcBg=; b=feXm/JN9UWhBBKpTvDWXF/Dxi6AXR/Wv+P5nDDfnE2bDNQmnVMrc9+hTroa5PnuQ050r bsO9Cfs4+pqWU7Y+6kfnGtyP4KL6/4mzvFeenD25tPhN03Bv6pak7ifrmYxPxtQj8+vUx 4uysF2j8yP0DcTP0W97YE9RiMSEHC8NKsjLAtMFFTJa2Q8zyyZDRO8RNOL2yS620bo2Qm QXH2qhgZsMGKafkHq3ljPPAb6cBh9Mct1ncqJCsvVvONsO4Rw6aO4EPPIe9INFjy/MU30 U0potd2o2JGZkKosOebePJLcafl/AhpyPTN4aCfc9TCdIRFddnRkuRALh1cPXnZ86QA== 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=RLoH6Dew; 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 57C2B606A322; Thu, 3 Dec 2026 07:21:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 57C2B606A322 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=RLoH6Dew 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 6B374gPd2737157; Thu, 3 Dec 2026 07:20:56 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=/S0wX/ Ix6lduOp3lBfTiH/yUzhQltEk0lIk/QS6DcBg=; b=RLoH6DewFfrTu6xz0YJWV8 U/JJ/vWY+paryd8GZeoQW5ppd8rCiRIRSOJLoZ13B7n2GCrQM/5YoGxLsULod94M wLov+B0RFpzlivwPrzeCAYVBIXY+Fel5Gk2rAddE/Cnqs0obRaiLgEIJ07DoWSpd lwchwbj0/Hqw+Ph4jOjGb4wZ5g8GKnUDFsOyKS6ORJAyX9YLrck205qDEMBqcl02 BfpjFd4tG5He5jcYv9wUc35UIDElcQZ0/t7mhEu2aBv9m8kWBcw6/X/DggVIlaNm nbkS2iTKlla4OfqTuc1ElNpHzB1IxJiAC2w1oXxNEzUkH467BFfo1ZKiNfVyHzbg == 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 4j7pkudrkf-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 03 Dec 2026 07:20:55 +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 6B36nSMt3197751; Thu, 3 Dec 2026 07:20:54 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ja0pq7bvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Dec 2026 07:20:54 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com [10.39.53.233]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B37KrH528770890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Dec 2026 07:20:54 GMT Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D82DC5804E; Thu, 3 Dec 2026 07:20:53 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED44358055; Thu, 3 Dec 2026 07:20:46 +0000 (GMT) Received: from [9.43.125.225] (unknown [9.43.125.225]) by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 3 Dec 2026 07:20:46 +0000 (GMT) Message-ID: <1bf819d9-fb9f-4f6c-adf2-4b289982fea6@linux.ibm.com> Date: Thu, 3 Dec 2026 12:50:45 +0530 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] net/smc: close non-accepted sockets without holding the listen lock To: Jiayi Zhang , "D. Wythe" , Dust Li , Sidraya Jayagond , Tony Lu , Wen Gu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: Willem de Bruijn , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, syzbot+621fd56ba002faba6392@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com References: <20261202175908.4136866-1-zhangjiayi1014@gmail.com> Content-Language: en-US From: Mahanta Jambigi In-Reply-To: <20261202175908.4136866-1-zhangjiayi1014@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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=6b111857 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=edf1wS77AAAA:8 a=hSkVLCK3AAAA:8 a=pGLkceISAAAA:8 a=n7JgutEtcU00j1LyeHgA:9 a=QEXdDO2ut3YA:10 a=DcSpbTIhAlouE1Uv7lRv:22 a=cQPPKAXgyycSBL8etih5:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAzMDAyOCBTYWx0ZWRfXwJQGrANR7UEZ ED4DbapTyzWfCRMah6ivsF8DW1Su52u5gDjwGf3pN8JnAORaFPwbvbL949Dnk+QxForVXgQigqe L1TB6JrdVKL7j4FPVrFpbBGv+tSjJ+Dlm0oFhmHB8qG5bWiz284chhbNTwLrKd5g7/o+wsC5XZz Ge6JyIa5OE/EAoMBiFVzbcHbG3+gEap+QMAG8tttxdpRgNDH3u9TUnIcUcEsuq+QPvTsoZXFX2i +mVPLmlxWvEAcf7rfGIAfsJe5UIe95bl6BfP/Lw+Mry3alq1CYmste9mE2nJgjUHZyCkchH4f5S YZ1cqg2lAfAcruQ/yXw0YXefFGBwp+sfABmHOWGOiHoCUiTDHK+RPNoUeopD5+EZ4A4gmKm/i4i ryTJ3AP6mIlV8rTwG2E+BOQUE7GDymjTp/TmyqR0a8QzZs7x3pxLXV/DsI9dqEXLAwhiRmMflNX Jf/UsYaS2XVXj+h/7MQ== X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAzMDAyOCBTYWx0ZWRfX1/P0+mohB1Z7 MsY7izOXSKlV+v5PJsFxYOxVdJ+yptsC7a6NQsJ+nxUBRS/5n2nwGsFzV3n2nkRHIm6T+92UuB0 6eYgdjWiU12ONRxNyZf9nF7/TgH+8Qw= X-Proofpoint-ORIG-GUID: XJpClqJAXIP15TWBCIydihitY_v2Qddw X-Proofpoint-GUID: eWHKxcdh_VndOzksX-m7Aep8_jEDw4I2 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-03_02,2026-12-02_07,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=1011 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612030028 Hi Jiayi, Thanks for the patch. The approach looks right to me. The deadlock is class-level only: a queued child's smc_listen_work() has already passed smc_listen_out() and does not take the listen lock again, so cancel_work_sync() never waits on a work that needs it. Moving the cleanup out of the lock breaks the lockdep cycle without freeing anything the listener still needs, and I could not find a correctness problem with the unlocked walk. Two things would make the changelog easier to review: 1. Say why shutdown() cannot race. A reviewer will ask about shutdown(SHUT_RDWR) on a listener. The SMC_LISTEN case in smc_close_active() is only reachable from smc_release(): smc_shutdown() returns -ENOTCONN for SMC_LISTEN, and the other __smc_release() caller, smc_close_non_accepted(), only sees children. That precondition is what makes "the last file reference is gone" true, so it is worth stating. 2. Spell out the queue locking while it is walked unlocked. The accept_q list is protected by accept_q_lock in smc_accept_enqueue() and smc_accept_unlink(), but sk_acceptq_added()/removed() update sk_ack_backlog under the listen lock. The state check plus flush_work(tcp_listen_work) is what rules out a concurrent enqueue or accept there; saying so makes the one-liner look less magical. On stable: there is no Cc: stable, but the Fixes tag may attract AUTOSEL. The backport is not safe without 185a4caeecab; you already say the patch depends on it, which is good. On my side: your note about my clcsock series is correct. Patch 3 adds a comment saying "the child and listener locks are held"; with this patch the listener lock is dropped on the cleanup path, so I will adjust that comment to refer to the child lock only. The reasoning in the comment still holds. One minor thing, not for this patch: after this change the lock_sock_nested(sk, SINGLE_DEPTH_NESTING) in smc_release() no longer describes a child-lock nesting for listeners. It is harmless and could be cleaned up separately. Thanks, Mahanta On 02/12/26 11:29 pm, Jiayi Zhang wrote: > syzbot reports a possible deadlock when a listening SMC socket is > closed: > > WARNING: possible circular locking dependency detected > ... > is trying to acquire lock: > ((work_completion)(&new_smc->smc_listen_work)), at: __flush_work > but task is already holding lock: > (sk_lock-AF_SMC/1), at: smc_release+0x3a5/0x620 net/smc/af_smc.c:353 > ... > -> #1 (sk_lock-AF_SMC/1): > lock_sock_nested+0x41/0xf0 net/core/sock.c:3909 > smc_listen_out+0xf2/0x4b0 net/smc/af_smc.c:1941 > ... > smc_listen_work+0x445/0x5040 net/smc/af_smc.c:2595 > -> #0 ((work_completion)(&new_smc->smc_listen_work)): > ... > cancel_work_sync+0xcc/0xf0 kernel/workqueue.c:4795 > smc_clcsock_release+0x5f/0xe0 net/smc/smc_close.c:29 > __smc_release+0x5c2/0x880 net/smc/af_smc.c:318 > smc_close_non_accepted+0xda/0x200 net/smc/af_smc.c:1871 > smc_close_cleanup_listen net/smc/smc_close.c:45 [inline] > smc_close_active+0x4ff/0x11a0 net/smc/smc_close.c:228 > __smc_release+0x634/0x880 net/smc/af_smc.c:294 > smc_release+0x1fc/0x620 net/smc/af_smc.c:361 > > smc_close_active() closes the sockets left on the accept queue of a > listening socket with smc_close_cleanup_listen() while it holds the lock > of the listening socket. Closing such a socket ends in > smc_clcsock_release(), which waits for the socket's smc_listen_work > with cancel_work_sync(). smc_listen_work() takes the lock of the > listening socket in smc_listen_out(). Commit fd57770dd198 ("net/smc: wait > for pending work before clcsock release_sock") added the > cancel_work_sync(). Because smc_listen_work() holds the lock of the new > socket, that commit made __smc_release() drop the socket's own lock > before smc_clcsock_release(). smc_close_cleanup_listen() still calls it > with the lock of the listening socket held. > > A socket on the accept queue has already passed that point: > smc_listen_out() puts it on the queue under the listen lock and does not > take that lock again. So this does not deadlock today, but lockdep > cannot tell the listen works apart and reports the dependency on every > such close. > > Close the non-accepted sockets after the listen lock is released, > together with the flush of tcp_listen_work that is already done there, > and take the lock again afterwards. The listening socket is already in > SMC_CLOSED at this point. Since commit 185a4caeecab ("net/smc: fix > TOCTOU race between smc_listen_out() and listener close"), > smc_listen_out() checks the state under the listen lock and closes a > new socket itself instead of queueing it, so the accept queue no longer > grows. This patch depends on that commit. accept() and poll() cannot run on the > socket any more because the last file reference is gone, so nothing > else walks the accept queue while smc_close_cleanup_listen() empties it. > > Fixes: fd57770dd198 ("net/smc: wait for pending work before clcsock release_sock") > Reported-by: syzbot+621fd56ba002faba6392@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=621fd56ba002faba6392 > Signed-off-by: Jiayi Zhang > --- > Tested with the syzbot C reproducer and the kernel config of the > report, 5 QEMU instances of 10 minutes each: without the patch all 5 > report the lockdep splat; with the patch none of the 5 reports anything. > The net selftests were not run. > > Mahanta Jambigi's series "net/smc: keep clcsock until socket release" > (net-next v3, posted 2026-12-01) adds a comment to > smc_accept_dequeue() saying that the child and listener locks are held. > With this patch that is no longer true on the cleanup path from > smc_close_active(). The two do not conflict textually. > > AI tools assisted with the analysis, the code and the changelog. > > net/smc/smc_close.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/smc/smc_close.c b/net/smc/smc_close.c > index 736abfb..2c98b77 100644 > --- a/net/smc/smc_close.c > +++ b/net/smc/smc_close.c > @@ -225,9 +225,9 @@ again: > write_unlock_bh(&smc->clcsock->sk->sk_callback_lock); > rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR); > } > - smc_close_cleanup_listen(sk); > release_sock(sk); > flush_work(&smc->tcp_listen_work); > + smc_close_cleanup_listen(sk); > lock_sock(sk); > break; > case SMC_ACTIVE: