Re: [PATCH] nbd: fix circular lock dependency

From: Guilherme Giacomo Simoes

Date: Wed Nov 11 2026 - 06:39:05 EST


Guilherme Giacomo Simoes <trintaeoitogc@xxxxxxxxx> wrote:
> > There is no real circular lock dependency here. This patch addresses a
> > lockdep false positive caused by the missing socket reclassification in
> > the reconnect path. Please change the subject into something like
> > "nbd: Also reclassify sockets in the reconnect path".
> >
> > > instead of the NBD-specific class leading to a possible lock dependency.
> >
> > Please change "possible lock dependency" into "lockdep false positive".
> >
> > > Reported-by: syzbot+d7d72f3d467710442af0@xxxxxxxxxxxxxxxxxxxxxxxxx
> > > Link: https://syzkaller.appspot.com/bug?extid=d7d72f3d467710442af0
> >
> > Please use Closes: instead of Link: for the syzbot report.
> Ok, I will send a V2
What do you think:
```
nbd: must reclassify socket when socket is created

When we need to connect or reconnect a new socket, we need to call
nbd_reclassify_socket() to ensure that a false positive lock_dep
circular warning fires. Inside nbd_add_socket(), after nbd_get_socket()
call he already call nbd_reclassify_socket(). However inside
nbd_genl_reconnect_sock_cb() the nbd_reclassify_socket() must be called
too and this is not doing.

To ensure that even when nbd_get_socket() is called the
nbd_reclassify_socket() will be called to, put the
nbd_reclassify_socket() inside nbd_get_socket().

Move the nbd_get_socket() bellow of nbd_reclassify_socket().

nbd_add_socket() no longer needs to do it.
```
?

> > If the reclassification should happen in nbd_get_socket(), please move
> > nbd_reclassify_socket() up instead of moving nbd_get_socket() down.
> I was have moved nbd_reclassify_socket up, just like you suggested, but git
> don't understanded this very well. But I will find way to get it
No , I couldn't do it :(

thanks,
Guilherme