======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.4.3474/14349 is trying to acquire lock:
ffff8881012b4980 (&root->kernfs_rwsem){++++}-{4:4}, at: kernfs_remove_by_name_ns+0x4e/0x140

but task is already holding lock:
ffff8881012b4aa0 (&root->kernfs_supers_rwsem){++++}-{4:4}, at: kernfs_remove_by_name_ns+0x3f/0x140

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #10 (&root->kernfs_supers_rwsem){++++}-{4:4}:
       down_read+0x47/0x2e0
       kernfs_remove_by_name_ns+0x3f/0x140
       sysfs_remove_group+0xfc/0x2e0
       sysfs_remove_groups+0x54/0xb0
       __kobject_del+0x84/0x330
       kobject_del+0x45/0x60
       irq_free_descs+0x196/0x2f0
       lan78xx_bind+0xa5b/0xd20
       lan78xx_probe+0x1058/0x1c10
       usb_probe_interface+0x659/0xc70
       really_probe+0x267/0xaf0
       __driver_probe_device+0x1ef/0x380
       driver_probe_device+0x4f/0x240
       __device_attach_driver+0x279/0x430
       bus_for_each_drv+0x258/0x2f0
       __device_attach+0x2c5/0x450
       device_initial_probe+0xa1/0xd0
       bus_probe_device+0x12a/0x220
       device_add+0x7e9/0xbb0
       usb_set_configuration+0x1a87/0x2110
       usb_generic_driver_probe+0x8d/0x150
       usb_probe_device+0x1c4/0x3b0
       really_probe+0x267/0xaf0
       __driver_probe_device+0x1ef/0x380
       driver_probe_device+0x4f/0x240
       __device_attach_driver+0x279/0x430
       bus_for_each_drv+0x258/0x2f0
       __device_attach+0x2c5/0x450
       device_initial_probe+0xa1/0xd0
       bus_probe_device+0x12a/0x220
       device_add+0x7e9/0xbb0
       usb_new_device+0xa08/0x16f0
       hub_event+0x2a1c/0x4f30
       process_scheduled_works+0xb5d/0x1860
       worker_thread+0xa53/0xfc0
       kthread+0x388/0x470
       ret_from_fork+0x514/0xb70
       ret_from_fork_asm+0x1a/0x30

-> #9 (sparse_irq_lock){+.+.}-{4:4}:
       __mutex_lock+0x1a3/0x1550
       cpuhp_bringup_ap+0x70/0x360
       cpuhp_invoke_callback+0x445/0x860
       _cpu_up+0x2ce/0x5b0
       cpu_up+0x1d2/0x220
       cpuhp_bringup_mask+0xb2/0x1a0
       cpuhp_bringup_cpus_parallel+0x118/0x120
       bringup_nonboot_cpus+0x17/0x30
       smp_init+0x32/0x110
       kernel_init_freeable+0x288/0x3e0
       kernel_init+0x1d/0x1d0
       ret_from_fork+0x514/0xb70
       ret_from_fork_asm+0x1a/0x30

-> #8 (cpu_hotplug_lock){++++}-{0:0}:
       cpus_read_lock+0x42/0x160
       static_key_slow_inc+0x12/0x30
       tcp_md5_do_add+0x1d4/0x390
       tcp_v6_parse_md5_keys+0x562/0x680
       do_tcp_setsockopt+0x12ec/0x2060
       do_sock_setsockopt+0x17c/0x1b0
       __x64_sys_setsockopt+0x13d/0x1b0
       do_syscall_64+0x15f/0xf80
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #7 (sk_lock-AF_INET6){+.+.}-{0:0}:
       lock_sock_nested+0x41/0x100
       inet_shutdown+0x6a/0x390
       nbd_mark_nsock_dead+0x2e9/0x560
       recv_work+0x1c2e/0x1d40
       process_scheduled_works+0xb5d/0x1860
       worker_thread+0xa53/0xfc0
       kthread+0x388/0x470
       ret_from_fork+0x514/0xb70
       ret_from_fork_asm+0x1a/0x30

-> #6 (&nsock->tx_lock){+.+.}-{4:4}:
       __mutex_lock+0x1a3/0x1550
       nbd_queue_rq+0x37b/0x1100
       blk_mq_dispatch_rq_list+0xa70/0x1910
       __blk_mq_sched_dispatch_requests+0xdcc/0x1600
       blk_mq_sched_dispatch_requests+0xd7/0x190
       blk_mq_run_hw_queue+0x348/0x4f0
       blk_mq_dispatch_list+0xd16/0xe10
       blk_mq_flush_plug_list+0x48d/0x570
       __blk_flush_plug+0x3ed/0x4d0
       __submit_bio+0x28d/0x580
       submit_bio_noacct_nocheck+0x2f4/0xa40
       block_read_full_folio+0x7b7/0x830
       filemap_read_folio+0x137/0x3b0
       do_read_cache_folio+0x358/0x590
       read_part_sector+0xb6/0x2b0
       adfspart_check_ICS+0xb1/0x960
       bdev_disk_changed+0x817/0x1770
       blkdev_get_whole+0x380/0x510
       bdev_open+0x31e/0xd30
       blkdev_open+0x470/0x610
       do_dentry_open+0x785/0x14e0
       vfs_open+0x3b/0x340
       path_openat+0x2e08/0x3860
       do_file_open+0x23e/0x4a0
       do_sys_openat2+0x113/0x200
       __x64_sys_openat+0x138/0x170
       do_syscall_64+0x15f/0xf80
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #5 (&cmd->lock){+.+.}-{4:4}:
       __mutex_lock+0x1a3/0x1550
       nbd_queue_rq+0xc6/0x1100
       blk_mq_dispatch_rq_list+0xa70/0x1910
       __blk_mq_sched_dispatch_requests+0xdcc/0x1600
       blk_mq_sched_dispatch_requests+0xd7/0x190
       blk_mq_run_hw_queue+0x348/0x4f0
       blk_mq_dispatch_list+0xd16/0xe10
       blk_mq_flush_plug_list+0x48d/0x570
       __blk_flush_plug+0x3ed/0x4d0
       __submit_bio+0x28d/0x580
       submit_bio_noacct_nocheck+0x2f4/0xa40
       block_read_full_folio+0x7b7/0x830
       filemap_read_folio+0x137/0x3b0
       do_read_cache_folio+0x358/0x590
       read_part_sector+0xb6/0x2b0
       adfspart_check_ICS+0xb1/0x960
       bdev_disk_changed+0x817/0x1770
       blkdev_get_whole+0x380/0x510
       bdev_open+0x31e/0xd30
       blkdev_open+0x470/0x610
       do_dentry_open+0x785/0x14e0
       vfs_open+0x3b/0x340
       path_openat+0x2e08/0x3860
       do_file_open+0x23e/0x4a0
       do_sys_openat2+0x113/0x200
       __x64_sys_openat+0x138/0x170
       do_syscall_64+0x15f/0xf80
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #4 (set->srcu){.+.+}-{0:0}:
       __synchronize_srcu+0xca/0x300
       elevator_switch+0x1e8/0x7a0
       elevator_change+0x2cc/0x450
       elevator_set_default+0x36c/0x430
       blk_register_queue+0x3e9/0x4e0
       __add_disk+0x677/0xd50
       add_disk_fwnode+0xfb/0x480
       nbd_dev_add+0x72c/0xb50
       nbd_init+0x168/0x1f0
       do_one_initcall+0x250/0x870
       do_initcall_level+0x104/0x190
       do_initcalls+0x59/0xa0
       kernel_init_freeable+0x2a6/0x3e0
       kernel_init+0x1d/0x1d0
       ret_from_fork+0x514/0xb70
       ret_from_fork_asm+0x1a/0x30

-> #3 (&q->elevator_lock){+.+.}-{4:4}:
       __mutex_lock+0x1a3/0x1550
       elevator_change+0x1b3/0x450
       elevator_set_none+0xb5/0x140
       blk_mq_update_nr_hw_queues+0x5e7/0x1a60
       nbd_start_device+0x17f/0xb10
       nbd_genl_connect+0x165b/0x1cf0
       genl_family_rcv_msg_doit+0x22a/0x330
       genl_rcv_msg+0x61c/0x7a0
       netlink_rcv_skb+0x232/0x4b0
       genl_rcv+0x28/0x40
       netlink_unicast+0x75c/0x8e0
       netlink_sendmsg+0x813/0xb40
       ____sys_sendmsg+0x972/0x9f0
       ___sys_sendmsg+0x2a5/0x360
       __x64_sys_sendmsg+0x1bd/0x2a0
       do_syscall_64+0x15f/0xf80
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&q->q_usage_counter(io)#51){++++}-{0:0}:
       blk_alloc_queue+0x546/0x680
       __blk_mq_alloc_disk+0x197/0x390
       nbd_dev_add+0x499/0xb50
       nbd_init+0x168/0x1f0
       do_one_initcall+0x250/0x870
       do_initcall_level+0x104/0x190
       do_initcalls+0x59/0xa0
       kernel_init_freeable+0x2a6/0x3e0
       kernel_init+0x1d/0x1d0
       ret_from_fork+0x514/0xb70
       ret_from_fork_asm+0x1a/0x30

-> #1 (fs_reclaim){+.+.}-{0:0}:
       fs_reclaim_acquire+0x71/0x100
       kmem_cache_alloc_lru_noprof+0x45/0x640
       alloc_inode+0xb8/0x1b0
       iget_locked+0x131/0x6a0
       kernfs_get_inode+0x4f/0x780
       kernfs_get_tree+0x5cd/0x980
       sysfs_get_tree+0x46/0x110
       vfs_get_tree+0x92/0x2a0
       do_new_mount+0x341/0xd30
       __se_sys_mount+0x31d/0x420
       do_syscall_64+0x15f/0xf80
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&root->kernfs_rwsem){++++}-{4:4}:
       __lock_acquire+0x15a5/0x2cf0
       lock_acquire+0x106/0x350
       down_write+0x96/0x200
       kernfs_remove_by_name_ns+0x4e/0x140
       sysfs_unmerge_group+0xd4/0x140
       dpm_sysfs_remove+0x5f/0xd0
       device_del+0x250/0x8f0
       device_destroy+0xb2/0x1a0
       tty_unregister_device+0x69/0x170
       gsm_cleanup_mux+0x4bb/0x9a0
       gsmld_close+0x48/0x120
       tty_ldisc_release+0x23f/0x520
       tty_release_struct+0x2a/0xd0
       tty_release+0xcb0/0x1710
       __fput+0x44f/0xa60
       task_work_run+0x1d9/0x270
       exit_to_user_mode_loop+0xed/0x480
       do_syscall_64+0x33e/0xf80
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  &root->kernfs_rwsem --> sparse_irq_lock --> &root->kernfs_supers_rwsem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&root->kernfs_supers_rwsem);
                               lock(sparse_irq_lock);
                               lock(&root->kernfs_supers_rwsem);
  lock(&root->kernfs_rwsem);

 *** DEADLOCK ***

4 locks held by syz.4.3474/14349:
 #0: ffff888171bda0a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_release+0xb8/0x520
 #1: ffff8881bb6140a0 (&tty->ldisc_sem/1){+.+.}-{0:0}, at: tty_ldisc_release+0xdc/0x520
 #2: ffff8881bc6380a8 (&gsm->mutex){+.+.}-{4:4}, at: gsm_cleanup_mux+0xb8/0x9a0
 #3: ffff8881012b4aa0 (&root->kernfs_supers_rwsem){++++}-{4:4}, at: kernfs_remove_by_name_ns+0x3f/0x140

stack backtrace:
CPU: 1 UID: 0 PID: 14349 Comm: syz.4.3474 Not tainted syzkaller #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+0xe8/0x150
 print_circular_bug+0x2e1/0x300
 check_noncircular+0x12e/0x150
 __lock_acquire+0x15a5/0x2cf0
 lock_acquire+0x106/0x350
 down_write+0x96/0x200
 kernfs_remove_by_name_ns+0x4e/0x140
 sysfs_unmerge_group+0xd4/0x140
 dpm_sysfs_remove+0x5f/0xd0
 device_del+0x250/0x8f0
 device_destroy+0xb2/0x1a0
 tty_unregister_device+0x69/0x170
 gsm_cleanup_mux+0x4bb/0x9a0
 gsmld_close+0x48/0x120
 tty_ldisc_release+0x23f/0x520
 tty_release_struct+0x2a/0xd0
 tty_release+0xcb0/0x1710
 __fput+0x44f/0xa60
 task_work_run+0x1d9/0x270
 exit_to_user_mode_loop+0xed/0x480
 do_syscall_64+0x33e/0xf80
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fbf0cb9cdd9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffebc040de8 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007fbf0ce17da0 RCX: 00007fbf0cb9cdd9
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 00007fbf0ce17da0 R08: 00007fbf0ce16038 R09: 0000000000000000
R10: 00000000005f1eb4 R11: 0000000000000246 R12: 0000000000054e46
R13: 00007fbf0ce1609c R14: 0000000000054b7c R15: 00007fbf0ce16090
 </TASK>
