Re: [PATCH] nbd: fix circular lock dependency

From: Hillf Danton

Date: Wed Nov 11 2026 - 19:13:56 EST


On Wed, 11 Nov 2026 09:13:45 -0800 Bart Van Assche wrote:
>On 11/11/26 3:38 AM, Guilherme Giacomo Simoes wrote:
> > After tested, how can I mention this in my patch?
>
>If syzbot confirms the fix, you can either:
>- Add a "Tested-by: syzbot..." tag if syzkaller provides one, or
>- Mention it below the "---" separator in your patch (in the changelog/notes
> section), e.g.:
> Tested against syzbot reproducer via #syz test: <link-to-syzbot-result>
>
> > What do you think now? We will call nbd_reclassify_socket() inside
> > nbd_get_socket() and call this only one time? Or is a better way call the
> > nbd_reclassify_socket() inside nbd_genl_reconnect_sock_cb() when we
>have sure
> > that we will use the socket?
>
>Calling nbd_reclassify_socket(sock) directly inside
>nbd_genl_reconnect_sock_cb() (right after nbd_get_socket()) is definitely
>the best approach:
>1. It is a 1-line addition to nbd_genl_reconnect_sock_cb().
>2. It mirrors what nbd_add_socket() already does.
>3. No code needs to be moved around, keeping the git diff minimal and making
> the fix trivial to review and backport to stable kernels.
>
> > 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. [...]
> > ```
>
> Please use the imperative mood, e.g. as follows:
>
> 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: syzbot+d7d72f3d467710442af0@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=d7d72f3d467710442af0
>
FYI reclassifying sockets is also corrupting memory [11], so can you fix
the corrupter before reclassifying again?

[11] Subject: [syzbot] BUG: spinlock already unlocked in corrupted
https://lore.kernel.org/lkml/6aec63fd.5f5735a5.290c1c.0003.GAE@xxxxxxxxxx/