Skip to contentSkip to conversation

nbd: don't warn when reclassifying a busy socket lock

PATCH Applied Deepanshu Kartikey 4 participants 16 messages Jun 21 – Aug 16

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

PATCH 1/1 nbd: don't warn when reclassifying a busy socket lock

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Hitting a held lock here is expected for an externally owned socket and is not a kernel bug, so skip reclassification silently instead of warning. Reclassification is a lockdep-only annotation, so skipping it in the rare racing case is harmless.

Reported-by [email protected]
Fixes d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency")
---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 3a585a0c882a..8f10762e90ef 100644
@@ -1246,7 +1246,7 @@ static void nbd_reclassify_socket(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 
-	if (WARN_ON_ONCE(!sock_allow_reclassification(sk)))
+	if (!sock_allow_reclassification(sk))
 		return;
 
 	switch (sk->sk_family) {
Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · On Mon, 22 Jun 2026 05:22:55 +0530 Deepanshu Kartikey wrote:

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

Quoted 9 lines

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Given the syzbot report, if you are right (I suspect) then Eric delivered another half-baked croissant, and feel free to cut it off instead to make room for correct fix.

Quoted 28 lines

Hitting a held lock here is expected for an externally owned socket and is not a kernel bug, so skip reclassification silently instead of warning. Reclassification is a lockdep-only annotation, so skipping it in the rare racing case is harmless.

Reported-by [email protected]
Fixes d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency")
---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 3a585a0c882a..8f10762e90ef 100644
@@ -1246,7 +1246,7 @@ static void nbd_reclassify_socket(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 
-	if (WARN_ON_ONCE(!sock_allow_reclassification(sk)))
+	if (!sock_allow_reclassification(sk))
 		return;
 
 	switch (sk->sk_family) {
Signature · 1 line
2.43.0
#2 lore raw
Quoted 17 lines · Hillf Danton
Quoted 6 lines · On Mon, 22 Jun 2026 05:22:55 +0530 Deepanshu Kartikey wrote:

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

Quoted 9 lines

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Quoted 3 lines

Given the syzbot report, if you are right (I suspect) then Eric delivered another half-baked croissant, and feel free to cut it off instead to make room for correct fix.

Nobody (including you) caught this.difference between nbd and other sock_allow_reclassification()
callers.

What was the "correct fix" you envisioned exactly?

#3 lore raw
Quoted 17 lines · On Mon, 22 Jun 2026 01:18:10 -0700 Eric Dumazet wrote:
Quoted 16 lines · Hillf Danton
Quoted 15 lines · On Mon, 22 Jun 2026 05:22:55 +0530 Deepanshu Kartikey wrote:

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Quoted 7 lines
Quoted 3 lines

Given the syzbot report, if you are right (I suspect) then Eric delivered another half-baked croissant, and feel free to cut it off instead to make room for correct fix.

Nobody (including you) caught this.difference between nbd and other sock_allow_reclassification() callers.

Nope, actually it raises the question -- does the deadlock still remain after your fix without the lock key you added applied?

Quoted 2 lines

What was the "correct fix" you envisioned exactly?

Frankly I had no evidence against your fix a couple days back, but now I see your lock key approach fails to take off. And the correct fix is to erase the incorrect locking order ffa1e7ada456 tries to catch, more difficult than you thought so far.

#4 lore raw
Quoted 23 lines · Hillf Danton
Quoted 21 lines · On Mon, 22 Jun 2026 01:18:10 -0700 Eric Dumazet wrote:
Quoted 19 lines · Hillf Danton
Quoted 6 lines · On Mon, 22 Jun 2026 05:22:55 +0530 Deepanshu Kartikey wrote:

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

Quoted 9 lines

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Given the syzbot report, if you are right (I suspect) then Eric delivered another half-baked croissant, and feel free to cut it off instead to make room for correct fix.

Quoted 5 lines
Quoted 3 lines

Nobody (including you) caught this.difference between nbd and other sock_allow_reclassification() callers.

Nope, actually it raises the question -- does the deadlock still remain after your fix without the lock key you added applied?

LOCKDEP might have a false positive, but it will be much much harder to trigger.

I had about 50 syzbot duplicates (that I did not release) before d532cddb6c60
("nbd: Reclassify sockets to avoid lockdep circular dependency").

Quoted 7 lines
Quoted 3 lines

What was the "correct fix" you envisioned exactly?

Frankly I had no evidence against your fix a couple days back, but now I see your lock key approach fails to take off. And the correct fix is to erase the incorrect locking order ffa1e7ada456 tries to catch, more difficult than you thought so far.

Which incorrect locking order are you referring to? This is a LOCKDEP false positive.

I suggest you send a patch so we can discuss it.

#5 lore raw
Quoted 37 lines · On Mon, 22 Jun 2026 17:21:53 -0700 Eric Dumazet wrote:
Quoted 22 lines · Hillf Danton
Quoted 21 lines · On Mon, 22 Jun 2026 01:18:10 -0700 Eric Dumazet wrote:
Quoted 19 lines · Hillf Danton
Quoted 6 lines · On Mon, 22 Jun 2026 05:22:55 +0530 Deepanshu Kartikey wrote:

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

Quoted 9 lines

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Given the syzbot report, if you are right (I suspect) then Eric delivered another half-baked croissant, and feel free to cut it off instead to make room for correct fix.

Quoted 5 lines
Quoted 3 lines

Nobody (including you) caught this.difference between nbd and other sock_allow_reclassification() callers.

Nope, actually it raises the question -- does the deadlock still remain after your fix without the lock key you added applied?

LOCKDEP might have a false positive, but it will be much much harder to trigger.

I had about 50 syzbot duplicates (that I did not release) before d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency").

Quoted 3 lines
Quoted 3 lines

What was the "correct fix" you envisioned exactly?

Quoted 8 lines
Quoted 4 lines

Frankly I had no evidence against your fix a couple days back, but now I see your lock key approach fails to take off. And the correct fix is to erase the incorrect locking order ffa1e7ada456 tries to catch, more difficult than you thought so far.

Which incorrect locking order are you referring to? This is a LOCKDEP false positive.

In addition to 50 syzbot reports, your fix has a Fixes tag, no?

Quoted 1 line

I suggest you send a patch so we can discuss it.

The deadlock existed before ffa1e7ada456, why is a chance left for your fix?

#6 lore raw
In reply to Eric Dumazet
Quoted 37 lines · On Mon, 22 Jun 2026 17:21:53 -0700 Eric Dumazet wrote:
Quoted 22 lines · Hillf Danton
Quoted 21 lines · On Mon, 22 Jun 2026 01:18:10 -0700 Eric Dumazet wrote:
Quoted 19 lines · Hillf Danton
Quoted 6 lines · On Mon, 22 Jun 2026 05:22:55 +0530 Deepanshu Kartikey wrote:

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

Quoted 9 lines

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Given the syzbot report, if you are right (I suspect) then Eric delivered another half-baked croissant, and feel free to cut it off instead to make room for correct fix.

Quoted 5 lines
Quoted 3 lines

Nobody (including you) caught this.difference between nbd and other sock_allow_reclassification() callers.

Nope, actually it raises the question -- does the deadlock still remain after your fix without the lock key you added applied?

LOCKDEP might have a false positive, but it will be much much harder to trigger.

I had about 50 syzbot duplicates (that I did not release) before d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency").

Quoted 3 lines
Quoted 3 lines

What was the "correct fix" you envisioned exactly?

Quoted 8 lines
Quoted 4 lines

Frankly I had no evidence against your fix a couple days back, but now I see your lock key approach fails to take off. And the correct fix is to erase the incorrect locking order ffa1e7ada456 tries to catch, more difficult than you thought so far.

Which incorrect locking order are you referring to? This is a LOCKDEP false positive.

For archive purpose, syzbot report [1] where udp was not invovled defies what is fixed in d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency") -- "Since the UDP socket and the NBD TCP/TLS socket are different, this is a false positive."

[1] Subject: [syzbot] [net?] possible deadlock in inet_shutdown (3)
https://lore.kernel.org/lkml/[email protected]/

#7 lore raw
Quoted 47 lines · Hillf Danton
Quoted 37 lines · On Mon, 22 Jun 2026 17:21:53 -0700 Eric Dumazet wrote:
Quoted 22 lines · Hillf Danton
Quoted 21 lines · On Mon, 22 Jun 2026 01:18:10 -0700 Eric Dumazet wrote:
Quoted 19 lines · Hillf Danton
Quoted 6 lines · On Mon, 22 Jun 2026 05:22:55 +0530 Deepanshu Kartikey wrote:

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

Quoted 9 lines

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Given the syzbot report, if you are right (I suspect) then Eric delivered another half-baked croissant, and feel free to cut it off instead to make room for correct fix.

Quoted 5 lines
Quoted 3 lines

Nobody (including you) caught this.difference between nbd and other sock_allow_reclassification() callers.

Nope, actually it raises the question -- does the deadlock still remain after your fix without the lock key you added applied?

LOCKDEP might have a false positive, but it will be much much harder to trigger.

I had about 50 syzbot duplicates (that I did not release) before d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency").

Quoted 3 lines
Quoted 3 lines

What was the "correct fix" you envisioned exactly?

Quoted 8 lines
Quoted 4 lines

Frankly I had no evidence against your fix a couple days back, but now I see your lock key approach fails to take off. And the correct fix is to erase the incorrect locking order ffa1e7ada456 tries to catch, more difficult than you thought so far.

Which incorrect locking order are you referring to? This is a LOCKDEP false positive.

Quoted 8 lines

For archive purpose, syzbot report [1] where udp was not invovled defies what is fixed in d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency") -- "Since the UDP socket and the NBD TCP/TLS socket are different, this is a false positive."

[1] Subject: [syzbot] [net?] possible deadlock in inet_shutdown (3)
https://lore.kernel.org/lkml/[email protected]/

Why don't you send a patch if you think one is needed?

#8 lore raw
Quoted 7 lines · On Tue, 30 Jun 2026 00:19:45 -0700 Eric Dumazet wrote:
Quoted 6 lines · Hillf Danton

For archive purpose, syzbot report [1] where udp was not invovled defies what is fixed in d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency") -- "Since the UDP socket and the NBD TCP/TLS socket are different, this is a false positive."

Quoted 5 lines
Quoted 2 lines

[1] Subject: [syzbot] [net?] possible deadlock in inet_shutdown (3)
https://lore.kernel.org/lkml/[email protected]/

Why don't you send a patch if you think one is needed?

Good question. It is a long standing tough issue, frankly more difficult than I could cure it in one shoot at the cost of a couple weeks, particularly given the rule of thumb -- delivering half baked croissants, HBC, as few as possible.

#9 lore raw
In reply to Hillf Danton
Quoted 9 lines · Hillf Danton

For archive purpose, syzbot report [1] where udp was not invovled defies what is fixed in d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency") -- "Since the UDP socket and the NBD TCP/TLS socket are different, this is a false positive."

[1] Subject: [syzbot] [net?] possible deadlock in inet_shutdown (3)
https://lore.kernel.org/lkml/[email protected]/

For archive purpose, syzbot report [2] shows deadlock without either udp or tcp invovled. But it sounds false positive because kernfs node is removed while the filesystem is filling super block.

[2] Subject: [syzbot] [kernfs?] possible deadlock in kernfs_remove_by_name_ns (2)
https://lore.kernel.org/lkml/[email protected]/

-> #1 (fs_reclaim){+.+.}-{0:0}:

       __fs_reclaim_acquire mm/page_alloc.c:4329 [inline]
       fs_reclaim_acquire+0x71/0x100 mm/page_alloc.c:4343
       might_alloc include/linux/sched/mm.h:317 [inline]
       slab_pre_alloc_hook mm/slub.c:4565 [inline]
       slab_alloc_node mm/slub.c:4925 [inline]
       kmem_cache_alloc_lru_noprof+0x65/0x5f0 mm/slub.c:4978
       alloc_inode+0xb8/0x1b0 fs/inode.c:340
       iget_locked+0x131/0x6a0 fs/inode.c:1477
       kernfs_get_inode+0x4f/0x770 fs/kernfs/inode.c:252
       kernfs_fill_super fs/kernfs/mount.c:308 [inline]
       kernfs_get_tree+0x5cd/0x980 fs/kernfs/mount.c:392
       vfs_get_tree+0x92/0x2a0 fs/super.c:1694
       fc_mount fs/namespace.c:1198 [inline]
       do_new_mount_fc fs/namespace.c:3765 [inline]
       do_new_mount+0x319/0xdc0 fs/namespace.c:3841
       do_mount fs/namespace.c:4174 [inline]
       __do_sys_mount fs/namespace.c:4390 [inline]
       __se_sys_mount+0x31d/0x420 fs/namespace.c:4367
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x174/0x580 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&root->kernfs_rwsem){++++}-{4:4}:

       check_prev_add kernel/locking/lockdep.c:3165 [inline]
       check_prevs_add kernel/locking/lockdep.c:3284 [inline]
       validate_chain kernel/locking/lockdep.c:3908 [inline]
       __lock_acquire+0x1520/0x2cf0 kernel/locking/lockdep.c:5237
       lock_acquire+0x106/0x350 kernel/locking/lockdep.c:5868
       down_write+0x96/0x200 kernel/locking/rwsem.c:1631
       kernfs_remove_by_name_ns+0x4e/0x140 fs/kernfs/dir.c:1792
       _cfg80211_unregister_wdev+0x133/0x5a0 net/wireless/core.c:1420
       ieee80211_if_remove+0x289/0x340 net/mac80211/iface.c:2432
       ieee80211_del_iface+0x19/0x30 net/mac80211/cfg.c:254
       rdev_del_virtual_intf net/wireless/rdev-ops.h:62 [inline]
       cfg80211_remove_virtual_intf+0x221/0x3f0 net/wireless/util.c:3006
       cfg80211_destroy_ifaces+0x23f/0x300 net/wireless/core.c:436
       cfg80211_destroy_iface_wk+0x21/0x30 net/wireless/core.c:464
       process_one_work kernel/workqueue.c:3322 [inline]
       process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405
       worker_thread+0xa47/0xfb0 kernel/workqueue.c:3486
       kthread+0x388/0x470 kernel/kthread.c:436
       ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
#10 lore raw
Quoted 10 lines · On Mon, 20 Jul 2026 10:23:43 +0800 Hillf Danton wrote:
Quoted 9 lines · Hillf Danton

For archive purpose, syzbot report [1] where udp was not invovled defies what is fixed in d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency") -- "Since the UDP socket and the NBD TCP/TLS socket are different, this is a false positive."

[1] Subject: [syzbot] [net?] possible deadlock in inet_shutdown (3)
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

For archive purpose, syzbot report [2] shows deadlock without either udp or tcp invovled. But it sounds false positive because kernfs node is removed while the filesystem is filling super block.

[2] Subject: [syzbot] [kernfs?] possible deadlock in kernfs_remove_by_name_ns (2)
https://lore.kernel.org/lkml/[email protected]/

For archive purpose, syzbot reports [3,4] show deadlock without either udp or tcp invovled.

[3] Subject: [syzbot] [kernfs?] possible deadlock in kernfs_iop_permission (2)
https://lore.kernel.org/lkml/[email protected]/

[4] Subject: [syzbot] [kernel?] possible deadlock in netif_reset_xps_queues_gt (3)
https://lore.kernel.org/lkml/[email protected]/

#11 lore raw
Quoted 18 lines · On Mon, 20 Jul 2026 10:39:17 +0800 Hillf Danton wrote:
Quoted 10 lines · On Mon, 20 Jul 2026 10:23:43 +0800 Hillf Danton wrote:
Quoted 9 lines · Hillf Danton

For archive purpose, syzbot report [1] where udp was not invovled defies what is fixed in d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency") -- "Since the UDP socket and the NBD TCP/TLS socket are different, this is a false positive."

[1] Subject: [syzbot] [net?] possible deadlock in inet_shutdown (3)
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

For archive purpose, syzbot report [2] shows deadlock without either udp or tcp invovled. But it sounds false positive because kernfs node is removed while the filesystem is filling super block.

[2] Subject: [syzbot] [kernfs?] possible deadlock in kernfs_remove_by_name_ns (2)
https://lore.kernel.org/lkml/[email protected]/

Quoted 9 lines

For archive purpose, syzbot reports [3,4] show deadlock without either udp or tcp invovled.

[3] Subject: [syzbot] [kernfs?] possible deadlock in kernfs_iop_permission (2)
https://lore.kernel.org/lkml/[email protected]/

[4] Subject: [syzbot] [kernel?] possible deadlock in netif_reset_xps_queues_gt (3)
https://lore.kernel.org/lkml/[email protected]/

For archive purpose, syzbot report [5] shows deadlock without lock_sock invovled.

[5] Subject: [syzbot] [pm?] possible deadlock in thermal_zone_device_set_mode
https://lore.kernel.org/lkml/[email protected]/

#12 lore raw
Quoted 25 lines · On Tue, 28 Jul 2026 12:53:37 +0800 Hillf Danton wrote:
Quoted 24 lines · On Mon, 20 Jul 2026 10:39:17 +0800 Hillf Danton wrote:
Quoted 10 lines · On Mon, 20 Jul 2026 10:23:43 +0800 Hillf Danton wrote:
Quoted 9 lines · Hillf Danton

For archive purpose, syzbot report [1] where udp was not invovled defies what is fixed in d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency") -- "Since the UDP socket and the NBD TCP/TLS socket are different, this is a false positive."

[1] Subject: [syzbot] [net?] possible deadlock in inet_shutdown (3)
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

For archive purpose, syzbot report [2] shows deadlock without either udp or tcp invovled. But it sounds false positive because kernfs node is removed while the filesystem is filling super block.

[2] Subject: [syzbot] [kernfs?] possible deadlock in kernfs_remove_by_name_ns (2)
https://lore.kernel.org/lkml/[email protected]/

For archive purpose, syzbot reports [3,4] show deadlock without either udp or tcp invovled.

[3] Subject: [syzbot] [kernfs?] possible deadlock in kernfs_iop_permission (2)
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 3 lines

[4] Subject: [syzbot] [kernel?] possible deadlock in netif_reset_xps_queues_gt (3)
https://lore.kernel.org/lkml/[email protected]/

For archive purpose, syzbot report [5] shows deadlock without lock_sock invovled.

[5] Subject: [syzbot] [pm?] possible deadlock in thermal_zone_device_set_mode
https://lore.kernel.org/lkml/[email protected]/

For archive purpose, syzbot report [6] shows deadlock without nbd invovled.

[6] Subject: [syzbot] [block?] [cgroups?] possible deadlock in blkcg_deactivate_policy (2)
https://lore.kernel.org/lkml/[email protected]/

BTW Eric do you see how difficult it is to fix the fking deadlock?

#13 lore raw
Quoted 31 lines · On Sun, 2 Aug 2026 16:19:20 +0800 Hillf Danton wrote:
Quoted 30 lines · On Tue, 28 Jul 2026 12:53:37 +0800 Hillf Danton wrote:
Quoted 18 lines · On Mon, 20 Jul 2026 10:39:17 +0800 Hillf Danton wrote:
Quoted 10 lines · On Mon, 20 Jul 2026 10:23:43 +0800 Hillf Danton wrote:
Quoted 9 lines · Hillf Danton

For archive purpose, syzbot report [1] where udp was not invovled defies what is fixed in d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency") -- "Since the UDP socket and the NBD TCP/TLS socket are different, this is a false positive."

[1] Subject: [syzbot] [net?] possible deadlock in inet_shutdown (3)
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

For archive purpose, syzbot report [2] shows deadlock without either udp or tcp invovled. But it sounds false positive because kernfs node is removed while the filesystem is filling super block.

[2] Subject: [syzbot] [kernfs?] possible deadlock in kernfs_remove_by_name_ns (2)
https://lore.kernel.org/lkml/[email protected]/

Quoted 9 lines

For archive purpose, syzbot reports [3,4] show deadlock without either udp or tcp invovled.

[3] Subject: [syzbot] [kernfs?] possible deadlock in kernfs_iop_permission (2)
https://lore.kernel.org/lkml/[email protected]/

[4] Subject: [syzbot] [kernel?] possible deadlock in netif_reset_xps_queues_gt (3)
https://lore.kernel.org/lkml/[email protected]/

For archive purpose, syzbot report [5] shows deadlock without lock_sock invovled.

Quoted 8 lines
Quoted 3 lines

[5] Subject: [syzbot] [pm?] possible deadlock in thermal_zone_device_set_mode
https://lore.kernel.org/lkml/[email protected]/

For archive purpose, syzbot report [6] shows deadlock without nbd invovled.

[6] Subject: [syzbot] [block?] [cgroups?] possible deadlock in blkcg_deactivate_policy (2)
https://lore.kernel.org/lkml/[email protected]/

For archive purpose, syzbot report [7] shows deadlock without socket invovled.

[7] Subject: [syzbot] [block?] [cgroups?] possible deadlock in blkg_conf_prep
https://lore.kernel.org/lkml/[email protected]/

BTW do you still have any interest/minute fixing it Eric?

Acked-by on v1 1/1
#14 lore raw
In reply to Deepanshu Kartikey
Quoted 17 lines · Deepanshu Kartikey

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Quoted 4 lines

Hitting a held lock here is expected for an externally owned socket and is not a kernel bug, so skip reclassification silently instead of warning. Reclassification is a lockdep-only annotation, so skipping it in the rare racing case is harmless.

Thanks!

maintainer Applied
#15 lore raw
In reply to Deepanshu Kartikey
Quoted 15 lines · Deepanshu Kartikey

nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is held at the point of reclassification. That assertion was copied from nvme-tcp, where the socket is created internally by the kernel (sock_create_kern()) and is never visible to user space, so the lock is guaranteed to be free.

NBD is different: the socket is looked up from a user-supplied fd in nbd_get_socket(), and user space retains that fd. A concurrent syscall on the same socket (or softirq processing taking bh_lock_sock() on a connected TCP socket) can legitimately hold the lock at the instant NBD reclassifies it. sock_allow_reclassification() then returns false and the WARN_ON_ONCE() fires, which turns into a crash under panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT against socket activity on the same fd, as reported by syzbot.

Quoted 1 line

[...]

Applied, thanks!

[1/1] nbd: don't warn when reclassifying a busy socket lock

      commit: 9280e6edf65662b6aafc8b704ad065b54c08b519

Best regards,

Signature · 1 line
Jens Axboe