======================================================
WARNING: possible circular locking dependency detected
6.16.0-rc3-syzkaller-00159-g223e2288f4b8-dirty #0 Not tainted
------------------------------------------------------
syz.0.79/6167 is trying to acquire lock:
ffffffff8e2257a8 (pcpu_alloc_mutex){+.+.}-{4:4}, at: pcpu_alloc_noprof+0x286/0x16b0

but task is already holding lock:
ffff8880206858b0 (&q->q_usage_counter(io)#49){++++}-{0:0}, at: nbd_start_device+0x16c/0xac0

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&q->q_usage_counter(io)#49){++++}-{0:0}:
       lock_acquire+0x120/0x360
       blk_alloc_queue+0x538/0x620
       __blk_mq_alloc_disk+0x162/0x340
       nbd_dev_add+0x476/0xb00
       nbd_init+0x21a/0x2d0
       do_one_initcall+0x236/0x820
       do_initcall_level+0x137/0x1f0
       do_initcalls+0x69/0xd0
       kernel_init_freeable+0x3d9/0x570
       kernel_init+0x1d/0x1d0
       ret_from_fork+0x3fc/0x770
       ret_from_fork_asm+0x1a/0x30

-> #1 (fs_reclaim){+.+.}-{0:0}:
       lock_acquire+0x120/0x360
       fs_reclaim_acquire+0x72/0x100
       prepare_alloc_pages+0x153/0x610
       __alloc_frozen_pages_noprof+0x123/0x370
       __alloc_pages_noprof+0xa/0x30
       pcpu_populate_chunk+0x182/0xb30
       pcpu_alloc_noprof+0xcbf/0x16b0
       xt_percpu_counter_alloc+0x161/0x220
       translate_table+0x12e9/0x2000
       ipt_register_table+0x106/0x7c0
       iptable_mangle_table_init+0x41/0x70
       xt_find_table_lock+0x30c/0x3e0
       xt_request_find_table_lock+0x26/0x100
       do_ipt_get_ctl+0x730/0x1180
       nf_getsockopt+0x26e/0x290
       ip_getsockopt+0x1c4/0x220
       do_sock_getsockopt+0x360/0x650
       __x64_sys_getsockopt+0x1a5/0x250
       do_syscall_64+0xfa/0x3b0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (pcpu_alloc_mutex){+.+.}-{4:4}:
       validate_chain+0xb9b/0x2140
       __lock_acquire+0xab9/0xd20
       lock_acquire+0x120/0x360
       __mutex_lock+0x182/0xe80
       pcpu_alloc_noprof+0x286/0x16b0
       sbitmap_init_node+0x1e1/0x630
       sbitmap_queue_init_node+0x41/0x660
       blk_mq_init_tags+0x110/0x280
       blk_mq_alloc_map_and_rqs+0xbd/0x9f0
       blk_mq_update_nr_hw_queues+0x76a/0x14c0
       nbd_start_device+0x16c/0xac0
       nbd_genl_connect+0x1250/0x1930
       genl_family_rcv_msg_doit+0x215/0x300
       genl_rcv_msg+0x60e/0x790
       netlink_rcv_skb+0x208/0x470
       genl_rcv+0x28/0x40
       netlink_unicast+0x75b/0x8d0
       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

other info that might help us debug this:

Chain exists of:
  pcpu_alloc_mutex --> fs_reclaim --> &q->q_usage_counter(io)#49

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&q->q_usage_counter(io)#49);
                               lock(fs_reclaim);
                               lock(&q->q_usage_counter(io)#49);
  lock(pcpu_alloc_mutex);

 *** DEADLOCK ***

7 locks held by syz.0.79/6167:
 #0: ffffffff8f576170 (cb_lock){++++}-{4:4}, at: genl_rcv+0x19/0x40
 #1: ffffffff8f575f88 (genl_mutex){+.+.}-{4:4}, at: genl_rcv_msg+0x10d/0x790
 #2: ffff8880207dca30 (&nbd->config_lock){+.+.}-{4:4}, at: nbd_genl_connect+0x94f/0x1930
 #3: ffff8880207dc988 (&set->update_nr_hwq_lock){++++}-{4:4}, at: blk_mq_update_nr_hw_queues+0x3b/0x14c0
 #4: ffff8880207dc8d8 (&set->tag_list_lock){+.+.}-{4:4}, at: blk_mq_update_nr_hw_queues+0x49/0x14c0
 #5: ffff8880206858b0 (&q->q_usage_counter(io)#49){++++}-{0:0}, at: nbd_start_device+0x16c/0xac0
 #6: ffff8880206858e8 (&q->q_usage_counter(queue)){+.+.}-{0:0}, at: nbd_start_device+0x16c/0xac0

stack backtrace:
CPU: 0 UID: 0 PID: 6167 Comm: syz.0.79 Not tainted 6.16.0-rc3-syzkaller-00159-g223e2288f4b8-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
 pcpu_alloc_noprof+0x286/0x16b0
 sbitmap_init_node+0x1e1/0x630
 sbitmap_queue_init_node+0x41/0x660
 blk_mq_init_tags+0x110/0x280
 blk_mq_alloc_map_and_rqs+0xbd/0x9f0
 blk_mq_update_nr_hw_queues+0x76a/0x14c0
 nbd_start_device+0x16c/0xac0
 nbd_genl_connect+0x1250/0x1930
 genl_family_rcv_msg_doit+0x215/0x300
 genl_rcv_msg+0x60e/0x790
 netlink_rcv_skb+0x208/0x470
 genl_rcv+0x28/0x40
 netlink_unicast+0x75b/0x8d0
 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
RIP: 0033:0x7f0066b8e929
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:00007f0067a0b038 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f0066db5fa0 RCX: 00007f0066b8e929
RDX: 0000000004010044 RSI: 0000200000000900 RDI: 0000000000000005
RBP: 00007f0066c10b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f0066db5fa0 R15: 00007ffd6050d9b8
 </TASK>
nbd0: detected capacity change from 0 to 8388607
