====================================================== WARNING: possible circular locking dependency detected 6.13.0-rc3-syzkaller-00017-gf44d154d6e3d #0 Not tainted ------------------------------------------------------ kworker/3:4/5975 is trying to acquire lock: ffff888021634a50 (&q->sysfs_lock){+.+.}-{4:4}, at: blk_unregister_queue+0xbc/0x2e0 block/blk-sysfs.c:854 but task is already holding lock: ffff888021634558 (&q->q_usage_counter(queue)#53){++++}-{0:0}, at: sd_remove+0x8f/0x150 drivers/scsi/sd.c:4072 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&q->q_usage_counter(queue)#53){++++}-{0:0}: blk_queue_enter+0x50f/0x640 block/blk-core.c:328 blk_mq_alloc_request+0x59b/0x950 block/blk-mq.c:652 scsi_alloc_request drivers/scsi/scsi_lib.c:1222 [inline] scsi_execute_cmd+0x1f1/0xff0 drivers/scsi/scsi_lib.c:304 read_capacity_10+0x1d4/0x6d0 drivers/scsi/sd.c:2766 sd_read_capacity drivers/scsi/sd.c:2834 [inline] sd_revalidate_disk.isra.0+0x3145/0xa8d0 drivers/scsi/sd.c:3734 sd_probe+0x8ee/0xfa0 drivers/scsi/sd.c:4010 call_driver_probe drivers/base/dd.c:579 [inline] really_probe+0x23e/0xa90 drivers/base/dd.c:658 __driver_probe_device+0x1de/0x440 drivers/base/dd.c:800 driver_probe_device+0x4c/0x1b0 drivers/base/dd.c:830 __device_attach_driver+0x1df/0x310 drivers/base/dd.c:958 bus_for_each_drv+0x157/0x1e0 drivers/base/bus.c:459 __device_attach_async_helper+0x1d3/0x290 drivers/base/dd.c:987 async_run_entry_fn+0x9c/0x530 kernel/async.c:129 process_one_work+0x958/0x1b30 kernel/workqueue.c:3229 process_scheduled_works kernel/workqueue.c:3310 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391 kthread+0x2c1/0x3a0 kernel/kthread.c:389 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 -> #1 (&q->limits_lock){+.+.}-{4:4}: __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x19b/0xa60 kernel/locking/mutex.c:735 queue_limits_start_update include/linux/blkdev.h:947 [inline] __blk_mq_update_nr_hw_queues+0x8b6/0x1500 block/blk-mq.c:5034 blk_mq_update_nr_hw_queues+0x2a/0x40 block/blk-mq.c:5068 nbd_start_device+0x15b/0xd70 drivers/block/nbd.c:1413 nbd_start_device_ioctl drivers/block/nbd.c:1464 [inline] __nbd_ioctl drivers/block/nbd.c:1539 [inline] nbd_ioctl+0x21a/0xfd0 drivers/block/nbd.c:1579 compat_blkdev_ioctl+0x2f7/0x750 block/ioctl.c:749 __do_compat_sys_ioctl+0x1cb/0x2c0 fs/ioctl.c:1004 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #0 (&q->sysfs_lock){+.+.}-{4:4}: check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain kernel/locking/lockdep.c:3904 [inline] __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5226 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x19b/0xa60 kernel/locking/mutex.c:735 blk_unregister_queue+0xbc/0x2e0 block/blk-sysfs.c:854 del_gendisk+0x2df/0xad0 block/genhd.c:710 sd_remove+0x8f/0x150 drivers/scsi/sd.c:4072 device_remove drivers/base/dd.c:569 [inline] device_remove+0x122/0x170 drivers/base/dd.c:561 __device_release_driver drivers/base/dd.c:1273 [inline] device_release_driver_internal+0x44a/0x610 drivers/base/dd.c:1296 bus_remove_device+0x22f/0x420 drivers/base/bus.c:576 device_del+0x396/0x9f0 drivers/base/core.c:3854 __scsi_remove_device+0x307/0x3d0 drivers/scsi/scsi_sysfs.c:1499 scsi_forget_host+0x138/0x190 drivers/scsi/scsi_scan.c:2068 scsi_remove_host+0xf8/0x320 drivers/scsi/hosts.c:181 quiesce_and_remove_host drivers/usb/storage/usb.c:949 [inline] usb_stor_disconnect+0x121/0x270 drivers/usb/storage/usb.c:1178 usb_unbind_interface+0x1e2/0x960 drivers/usb/core/driver.c:458 device_remove drivers/base/dd.c:569 [inline] device_remove+0x122/0x170 drivers/base/dd.c:561 __device_release_driver drivers/base/dd.c:1273 [inline] device_release_driver_internal+0x44a/0x610 drivers/base/dd.c:1296 bus_remove_device+0x22f/0x420 drivers/base/bus.c:576 device_del+0x396/0x9f0 drivers/base/core.c:3854 usb_disable_device+0x36c/0x7f0 drivers/usb/core/message.c:1418 usb_disconnect+0x2e1/0x920 drivers/usb/core/hub.c:2304 hub_port_connect drivers/usb/core/hub.c:5361 [inline] hub_port_connect_change drivers/usb/core/hub.c:5661 [inline] port_event drivers/usb/core/hub.c:5821 [inline] hub_event+0x1da5/0x4e10 drivers/usb/core/hub.c:5903 process_one_work+0x958/0x1b30 kernel/workqueue.c:3229 process_scheduled_works kernel/workqueue.c:3310 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391 kthread+0x2c1/0x3a0 kernel/kthread.c:389 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 other info that might help us debug this: Chain exists of: &q->sysfs_lock --> &q->limits_lock --> &q->q_usage_counter(queue)#53 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&q->q_usage_counter(queue)#53); lock(&q->limits_lock); lock(&q->q_usage_counter(queue)#53); lock(&q->sysfs_lock); *** DEADLOCK *** 8 locks held by kworker/3:4/5975: #0: ffff888043edb548 ((wq_completion)usb_hub_wq){+.+.}-{0:0}, at: process_one_work+0x12cd/0x1b30 kernel/workqueue.c:3204 #1: ffffc90003677d80 ((work_completion)(&hub->events)){+.+.}-{0:0}, at: process_one_work+0x8bb/0x1b30 kernel/workqueue.c:3205 #2: ffff8880466f7190 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline] #2: ffff8880466f7190 (&dev->mutex){....}-{4:4}, at: hub_event+0x1c1/0x4e10 drivers/usb/core/hub.c:5849 #3: ffff8880728b2190 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline] #3: ffff8880728b2190 (&dev->mutex){....}-{4:4}, at: usb_disconnect+0x10a/0x920 drivers/usb/core/hub.c:2295 #4: ffff888067d83160 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline] #4: ffff888067d83160 (&dev->mutex){....}-{4:4}, at: __device_driver_lock drivers/base/dd.c:1095 [inline] #4: ffff888067d83160 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0xa4/0x610 drivers/base/dd.c:1293 #5: ffff88804c15c0e0 (&shost->scan_mutex){+.+.}-{4:4}, at: scsi_remove_host+0x26/0x320 drivers/scsi/hosts.c:169 #6: ffff888025e68378 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline] #6: ffff888025e68378 (&dev->mutex){....}-{4:4}, at: __device_driver_lock drivers/base/dd.c:1095 [inline] #6: ffff888025e68378 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0xa4/0x610 drivers/base/dd.c:1293 #7: ffff888021634558 (&q->q_usage_counter(queue)#53){++++}-{0:0}, at: sd_remove+0x8f/0x150 drivers/scsi/sd.c:4072 stack backtrace: CPU: 3 UID: 0 PID: 5975 Comm: kworker/3:4 Not tainted 6.13.0-rc3-syzkaller-00017-gf44d154d6e3d #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_circular_bug+0x41c/0x610 kernel/locking/lockdep.c:2074 check_noncircular+0x31a/0x400 kernel/locking/lockdep.c:2206 check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain kernel/locking/lockdep.c:3904 [inline] __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5226 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x19b/0xa60 kernel/locking/mutex.c:735 blk_unregister_queue+0xbc/0x2e0 block/blk-sysfs.c:854 del_gendisk+0x2df/0xad0 block/genhd.c:710 sd_remove+0x8f/0x150 drivers/scsi/sd.c:4072 device_remove drivers/base/dd.c:569 [inline] device_remove+0x122/0x170 drivers/base/dd.c:561 __device_release_driver drivers/base/dd.c:1273 [inline] device_release_driver_internal+0x44a/0x610 drivers/base/dd.c:1296 bus_remove_device+0x22f/0x420 drivers/base/bus.c:576 device_del+0x396/0x9f0 drivers/base/core.c:3854 __scsi_remove_device+0x307/0x3d0 drivers/scsi/scsi_sysfs.c:1499 scsi_forget_host+0x138/0x190 drivers/scsi/scsi_scan.c:2068 scsi_remove_host+0xf8/0x320 drivers/scsi/hosts.c:181 quiesce_and_remove_host drivers/usb/storage/usb.c:949 [inline] usb_stor_disconnect+0x121/0x270 drivers/usb/storage/usb.c:1178 usb_unbind_interface+0x1e2/0x960 drivers/usb/core/driver.c:458 device_remove drivers/base/dd.c:569 [inline] device_remove+0x122/0x170 drivers/base/dd.c:561 __device_release_driver drivers/base/dd.c:1273 [inline] device_release_driver_internal+0x44a/0x610 drivers/base/dd.c:1296 bus_remove_device+0x22f/0x420 drivers/base/bus.c:576 device_del+0x396/0x9f0 drivers/base/core.c:3854 usb_disable_device+0x36c/0x7f0 drivers/usb/core/message.c:1418 usb_disconnect+0x2e1/0x920 drivers/usb/core/hub.c:2304 hub_port_connect drivers/usb/core/hub.c:5361 [inline] hub_port_connect_change drivers/usb/core/hub.c:5661 [inline] port_event drivers/usb/core/hub.c:5821 [inline] hub_event+0x1da5/0x4e10 drivers/usb/core/hub.c:5903 process_one_work+0x958/0x1b30 kernel/workqueue.c:3229 process_scheduled_works kernel/workqueue.c:3310 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391 kthread+0x2c1/0x3a0 kernel/kthread.c:389 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244