mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
To: Josef Bacik <josef@toxicpanda.com>, Jens Axboe <axboe@kernel.dk>
Cc: Eric Dumazet <edumazet@google.com>,
	linux-block@vger.kernel.org, nbd@other.debian.org,
	linux-kernel@vger.kernel.org,
	Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Subject: [PATCH] nbd: reclassify the socket lock on reconnect too
Date: Wed, 28 Oct 2026 21:22:35 +0700	[thread overview]
Message-ID: <20261028142235.24675-1-ngocthang2710.1999@gmail.com> (raw)

Commit d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular
dependency") moves nbd sockets to their own lockdep class, but only in
nbd_add_socket(). A socket installed by NBD_CMD_RECONFIGURE keeps the
generic sk_lock-AF_INET class, so the false positive comes back as soon
as recv_work() shuts it down under tx_lock:

  WARNING: possible circular locking dependency detected
  kworker/u20:0/67 is trying to acquire lock:
  (sk_lock-AF_INET){+.+.}-{0:0}, at: inet_shutdown+0x67/0x410
  but task is already holding lock:
  (&nsock->tx_lock){+.+.}-{4:4}, at: recv_work+0x657/0xa70
  ...
  Chain exists of:
    sk_lock-AF_INET --> &cmd->lock --> &nsock->tx_lock

Reclassify the socket in the reconnect path as well.

Fixes: d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency")
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
---
Found while testing the fix for
https://syzkaller.appspot.com/bug?extid=a246ab421a728c78b4ad
("nbd: don't take cpu_hotplug_lock under tx_lock on reconnect", sent
separately): once that splat is gone, the same reproducer reports this
one. Independent of that patch; applies on its own.

Tested in x86_64 QEMU (KASAN + PROVE_LOCKING): with both fixes the
reproducer runs clean 5/5.

 drivers/block/nbd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index a567c0bce90e..b24f69a2bd82 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1357,6 +1357,7 @@ static int nbd_genl_reconnect_sock_cb(struct nbd_device *nbd, unsigned long arg)
 	sock = nbd_get_socket(nbd, arg, &err);
 	if (!sock)
 		return err;
+	nbd_reclassify_socket(sock);
 
 	args = kzalloc_obj(*args);
 	if (!args) {
-- 
2.43.0


                 reply	other threads:[~2026-10-28 14:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261028142235.24675-1-ngocthang2710.1999@gmail.com \
    --to=ngocthang2710.1999@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=edumazet@google.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nbd@other.debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®