======================================================
WARNING: possible circular locking dependency detected
6.16.0-rc5-syzkaller-00193-g40f92e79b0aa-dirty #0 Not tainted
------------------------------------------------------
syz.4.14525/11149 is trying to acquire lock:
ffff8881088ce358 (&disk->open_mutex){+.+.}-{4:4}, at: __del_gendisk+0x129/0x9e0

but task is already holding lock:
ffff8881088cd368 (&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_ioctl+0x636/0xeb0
       blkdev_ioctl+0x5a8/0x6d0
       __se_sys_ioctl+0xfc/0x170
       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.4.14525/11149:
 #0: ffff8881088cd368 (&set->update_nr_hwq_lock){++++}-{4:4}, at: del_gendisk+0xe0/0x160

stack backtrace:
CPU: 0 UID: 0 PID: 11149 Comm: syz.4.14525 Not tainted 6.16.0-rc5-syzkaller-00193-g40f92e79b0aa-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:0x7facea18e929
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:00007faceaff3038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007facea3b5fa0 RCX: 00007facea18e929
RDX: 0000000000000002 RSI: 0000000000004c81 RDI: 0000000000000006
RBP: 00007facea210b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007facea3b5fa0 R15: 00007fff04344658
 </TASK>
