[PATCH V2] nbd: Reclassify sockets in the reconnect path

From: Guilherme Giacomo Simoes

Date: Thu Nov 12 2026 - 07:12:10 EST


Commit d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular
dependency") introduced nbd_reclassify_socket() to prevent lockdep false
positives when NBD sockets are used in memory reclaim paths. While
nbd_add_socket() reclassifies newly added sockets,
nbd_genl_reconnect_sock_cb() omitted this call when replacing dead
sockets during reconnection. Consequently, reconnected sockets retain
the generic socket lockdep class and trigger false-positive lockdep
reports.

Fix this by reclassifying the replacement socket in
nbd_genl_reconnect_sock_cb().

Fixes: d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency")
Reported-by: syzbot+d7d72f3d467710442af0@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=d7d72f3d467710442af0
Signed-off-by: Guilherme Giacomo Simoes <trintaeoitogc@xxxxxxxxx>
---
v2:
- change previous patch to a single line addition of
nbd_reclassify_socket()
- improve commit message

v1:
https://lore.kernel.org/all/20261110215723.199948-1-trintaeoitogc@xxxxxxxxx/
---
drivers/block/nbd.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index ffce519bf008..b2b27f90a7ed 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1356,6 +1356,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.52.0