From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.229.8 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796234360; b=af9oez3uzaV8X3Jt6cjP4dz+SlUDe7lrDkJ6rDs5eFVNoEvjdnWMZtb7fZypWyt7zmYL eJ1ppVN3EbxWnTeOw77Stx2+FZFYOElxOHYa5gVeGe4zq5xhLsds9fhk0xFc2O5GgdbOx JkJpTQT5R+HO1aF6yGAHqsltoEGtyqpENtSNjGp5tQnzDvCQ+LQaBhPQimPIkErKDfBto HbHK0jSOe1XNSCLDkieV/myOwNKPXPgRkwiudDzc9TcZCVYZqsxdxmsLebgVp4CEbJAWS T+t/9FBL+ca1n1mRENjP6PN0NZG0vNuvpxvrgvXyTpNQTZvV5NTKboGchtUF6W+WLXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796234360; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=cUQSNTA9tzrCZyUbZNDRfJBy2drVzp2dkawB8wYlexw=; b=e+K3qalD1PVLkbHxkyOg0d5wOky0AHAN31GEnYah4VF8zYzK5J8n0aTj9JuJuEiz6ULO 8pBALnBHGR84q0XGDKZI7Fnp864R3PMu3vY0KefzM9ZdY29/9VufV15fZDkxtlwY94cH8 s37JEMYbYZ9azhzNcagViXEH9LMYOE13ssNyz2MtyA/w6v/OkgYxZFBCJj+bO1w7Y2D+4 Rb9QTZ3s2krw14wO8oa6rCeIM8yUAeF9z2cqs5j/+YRu49IZMEsP+9R4lXpPuTwgtBAeB CDNTkQbtuDyVwM5ibeQITMJT8x+Z5bvTlgDbS4rDMl9Axv6V8YEih8wqjwerozv69ng== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ODFzHYhw; arc=none smtp.remote-ip=74.125.229.8 Received: from mail-dy2-f8.google.com (mail-dy2-f8.google.com [74.125.229.8]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1AC9606A33A for ; Wed, 2 Dec 2026 17:59:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F1AC9606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ODFzHYhw Received: by mail-dy2-f8.google.com with SMTP id 5a478bee46e88-382afece6d8so2860598eec.1 for ; Wed, 02 Dec 2026 09:59:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796234359; x=1796839159; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=cUQSNTA9tzrCZyUbZNDRfJBy2drVzp2dkawB8wYlexw=; b=ODFzHYhwWRbUFjlqb3sjP1vgE0BK14CPGhx+HxaL0B8KbDksSxzMkGZvrgUEZKzrS+ BhJ0tzAjtIUce30U6NhebbElxWYiHjlaqTuY2mtptXiLoCxozb4LyYUhmvVRXcJqXuP7 quuMTIT3rH/zfhrwWN+65SJphBW9iroAnyEeMS8N1lSQEB06gGkEGVQHu/UIMxUTcK8d w75Gq2KSUq2PC610O7YAn/RO7VdUxKssJFQQLEAthbrZ5tok4UaZf16mCYDZ7a7Y1W6d 57eU9MWeCDhZVY2zWGz0pw/7fQ0PXF93ftFKbZYzE7h1EmnObaR6hlZUJlCN4IAjMr8b wPnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796234359; x=1796839159; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cUQSNTA9tzrCZyUbZNDRfJBy2drVzp2dkawB8wYlexw=; b=mtiHeNmWL4kzcArC7kHigv0nXJzdHaq9LsGYlAPTPKd0aXPdgVx/cLmmbTKjDxwQTb gDzK2BaiyZbLA/SjMehYkpRYZe43csYgdNPfFbK9i23Pz8sbGHv6mQH2fqmMiovdu6qF zZeU8vsqcxLH0dd/yD2OdAmhu8Y3lNXxj6G+VNYmdV5vnuZ+x7AY7qWtI5nXx1QHdJKa WTCRNbwC3+6ukbwqm1hmJ4mRRsx8B2gk/7nqeXCEHtB9nFQxDlv4R3R5pwU2oiDchzqB uCTZn4Sr97VyQ7sWfJVCkc0JhxmMshjBgoMF83qQy9ma/OQKJzG5gg04ds2sdN2/S20t Q43Q== X-Forwarded-Encrypted: i=1; AL+hErGANz9+ZFmKVr1wEiyPG1Z3HAdtyU0Mwdlt8ZaigyKvvL7WZm1bt53uB6ITVHWBpcbCL+kyr1M=@vger.kernel.org X-Gm-Message-State: APuU4Z/uKOEyPecKWt1PYiGLfybh0HRr4MUQGZ1XOVAVYkVW8LKlQzra G10XcyWy8xWZFQM5h4h3gGpH9JWJHkjctMHOOcJZLDR2/YhOApWutvXV X-Gm-Gg: AZFdTZddpE70pFTbkMpeZu9+dbel3LaXSh0ii2NBCfRSpv+is4PufaO/kBMXO3+N7tC 0T24/2aQ+MdOOObjH+5yKFA/BP/d4XBttdNQanfrmdC95dq2h6f6GplVKN8VovSIewKESu3439w cg6ejsPvzmTgpUOj5sL8I8tQ8zBIkqt6Z50S2JXOe9ecmcLtRHbaPFy74OOyv1rIm6knjf4LnIq GRjCRpfoupfssC8emaBdLKiJOYVqgyVCF3de/mtuQKg3WlF0jBpRyJg873RbtXQw507oXKx0KG8 8sdkQAf1jkF/G4GCZNpscGOo9H+V2r9ydej1nld88HLYasXRJ3zVM2XIYiBJPPPIHDdnNoFvykN Yc6J6TCX9jm4kMlF+XemaVuvGhHjBP7C48O54K5Zb3WxbVTW1o7DjqHXMNEG0y/z16XJiXdJLKw 3owdDqr6IJO0ZuqcGUk2FvRSUyNlq2JrayeC2Qdf88VS1DRpJbLSnOaHpM6+GlxfWk5rBpNFE2T H8dsJjofb/OTzkuikqqk2X+x8+iZlCcoMO4kyMKGkauY7xGEamPj69+YjLsDgpI/xsoLDZEclaz o/lN1SceB85Rt7RfaUaWDsMaF8AUOa6aTE7IK/3774wVQAADqez8c92/ X-Received: by 2002:a05:7301:6188:10b0:386:9ba8:2864 with SMTP id 5a478bee46e88-3869ba82acfmr33514669eec.0.1796234358897; Wed, 02 Dec 2026 09:59:18 -0800 (PST) Received: from jiayi-vm-sprl-server17.local ([155.69.195.24]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38566cd46c5sm152475446eec.11.2026.12.02.09.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 09:59:18 -0800 (PST) From: Jiayi Zhang To: "D. Wythe" , Dust Li , Sidraya Jayagond , Mahanta Jambigi , 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 Subject: [PATCH net] net/smc: close non-accepted sockets without holding the listen lock Date: Wed, 2 Dec 2026 17:59:08 +0000 Message-ID: <20261202175908.4136866-1-zhangjiayi1014@gmail.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: 8bit 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: -- 2.53.0