Skip to contentSkip to conversation

nbd: Reclassify sockets in the reconnect path

PATCH Applied Guilherme Giacomo Simoes 3 participants 3 messages Nov 12 – Nov 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nbd: Reclassify sockets in the reconnect path

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 [email protected]

---
v2:
- change previous patch to a single line addition of nbd_reclassify_socket()
- improve commit message

v1:
https://lore.kernel.org/all/[email protected]/

---
 drivers/block/nbd.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/nbd.c +1 -0
index ffce519bf008..b2b27f90a7ed 100644
@@ -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) {
Signature · 1 line
2.52.0
Reviewed-by on v2 1/1
#1 lore raw

drivers/block/nbd.c static int nbd_genl_reconnect_sock_cb(struct nbd_device *nbd, unsigned long arg) · line 1362

Quoted 12 lines · Guilherme Giacomo Simoes
drivers/block/nbd.c +1 -0
index ffce519bf008..b2b27f90a7ed 100644
@@ -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) {
maintainer Applied
#2 lore raw
In reply to Guilherme Giacomo Simoes
Quoted 10 lines · Guilherme Giacomo Simoes

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.

[...]

Applied, thanks!

[1/1] nbd: Reclassify sockets in the reconnect path

      commit: 553d28925fdea4044bad4ae1e2bf9484ad21f758

Best regards,

Signature · 1 line
Jens Axboe