mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nbd: reclassify the socket lock on reconnect too
@ 2026-10-28 14:22 Nguyen Ngoc Thang
  0 siblings, 0 replies; only message in thread
From: Nguyen Ngoc Thang @ 2026-10-28 14:22 UTC (permalink / raw)
  To: Josef Bacik, Jens Axboe
  Cc: Eric Dumazet, linux-block, nbd, linux-kernel, Nguyen Ngoc Thang

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-28 14:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28 14:22 [PATCH] nbd: reclassify the socket lock on reconnect too Nguyen Ngoc Thang

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®