======================================================
WARNING: possible circular locking dependency detected
6.16.0-rc7-syzkaller-dirty #0 Not tainted
------------------------------------------------------
syz.0.7175/24802 is trying to acquire lock:
ffff888107557358 (&disk->open_mutex){+.+.}-{4:4}, at: __del_gendisk+0x129/0x9e0

but task is already holding lock:
ffff888107556368 (&set->update_nr_hwq_lock){++++}-{4:4}, at: del_gendisk+0xe0/0x160

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&set->update_nr_hwq_lock){++++}-{4:4}:
       lock_acquire+0x120/0x360
       down_write+0x96/0x1f0
       blk_mq_update_nr_hw_queues+0x3b/0x14c0
       nbd_start_device+0x16c/0xac0
       nbd_genl_connect+0x135b/0x18f0
       genl_family_rcv_msg_doit+0x215/0x300
       genl_rcv_msg+0x60e/0x790
       netlink_rcv_skb+0x208/0x470
       genl_rcv+0x28/0x40
       netlink_unicast+0x75c/0x8e0
       netlink_sendmsg+0x805/0xb30
       __sock_sendmsg+0x21c/0x270
       ____sys_sendmsg+0x505/0x830
       ___sys_sendmsg+0x21f/0x2a0
       __x64_sys_sendmsg+0x19b/0x260
       do_syscall_64+0xfa/0x3b0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&nbd->config_lock){+.+.}-{4:4}:
       lock_acquire+0x120/0x360
       __mutex_lock+0x182/0xe80
       refcount_dec_and_mutex_lock+0x30/0xa0
       nbd_config_put+0x2c/0x790
       nbd_release+0xfe/0x140
       bdev_release+0x536/0x650
       blkdev_release+0x15/0x20
       __fput+0x44c/0xa70
       fput_close_sync+0x119/0x200
       __x64_sys_close+0x7f/0x110
       do_syscall_64+0xfa/0x3b0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&disk->open_mutex){+.+.}-{4:4}:
       validate_chain+0xb9b/0x2140
       __lock_acquire+0xab9/0xd20
       lock_acquire+0x120/0x360
       __mutex_lock+0x182/0xe80
       __del_gendisk+0x129/0x9e0
       del_gendisk+0xe8/0x160
       loop_remove+0x42/0xc0
       loop_control_ioctl+0x4ac/0x5a0
       __se_sys_ioctl+0xfc/0x170
       do_syscall_64+0xfa/0x3b0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  &disk->open_mutex --> &nbd->config_lock --> &set->update_nr_hwq_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&set->update_nr_hwq_lock);
                               lock(&nbd->config_lock);
                               lock(&set->update_nr_hwq_lock);
  lock(&disk->open_mutex);

 *** DEADLOCK ***

1 lock held by syz.0.7175/24802:
 #0: ffff888107556368 (&set->update_nr_hwq_lock){++++}-{4:4}, at: del_gendisk+0xe0/0x160

stack backtrace:
CPU: 0 UID: 0 PID: 24802 Comm: syz.0.7175 Not tainted 6.16.0-rc7-syzkaller-dirty #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250
 print_circular_bug+0x2ee/0x310
 check_noncircular+0x134/0x160
 validate_chain+0xb9b/0x2140
 __lock_acquire+0xab9/0xd20
 lock_acquire+0x120/0x360
 __mutex_lock+0x182/0xe80
 __del_gendisk+0x129/0x9e0
 del_gendisk+0xe8/0x160
 loop_remove+0x42/0xc0
 loop_control_ioctl+0x4ac/0x5a0
 __se_sys_ioctl+0xfc/0x170
 do_syscall_64+0xfa/0x3b0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fb9c058e9a9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb9c13f9038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fb9c07b6160 RCX: 00007fb9c058e9a9
RDX: 0000000000000000 RSI: 0000000000004c81 RDI: 0000000000000003
RBP: 00007fb9c0610d69 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fb9c07b6160 R15: 00007ffeee980d58
 </TASK>
