public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [scsi?] possible deadlock in sd_remove
@ 2024-11-06  2:29 syzbot
  2024-12-31  8:00 ` syzbot
  2025-01-01  9:20 ` syzbot
  0 siblings, 2 replies; 5+ messages in thread
From: syzbot @ 2024-11-06  2:29 UTC (permalink / raw)
  To: James.Bottomley, linux-kernel, linux-scsi, martin.petersen,
	syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    c88416ba074a Add linux-next specific files for 20241101
git tree:       linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=165f0740580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=704b6be2ac2f205f
dashboard link: https://syzkaller.appspot.com/bug?extid=566d48f3784973a22771
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/760a8c88d0c3/disk-c88416ba.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/46e4b0a851a2/vmlinux-c88416ba.xz
kernel image: https://storage.googleapis.com/syzbot-assets/428e2c784b75/bzImage-c88416ba.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+566d48f3784973a22771@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
6.12.0-rc5-next-20241101-syzkaller #0 Not tainted
------------------------------------------------------
kworker/1:5/15509 is trying to acquire lock:
ffff8880315343e0 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: rcu_lock_acquire include/linux/rcupdate.h:337 [inline]
ffff8880315343e0 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
ffff8880315343e0 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: start_flush_work kernel/workqueue.c:4123 [inline]
ffff8880315343e0 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: __flush_work+0xe7/0xc50 kernel/workqueue.c:4181

but task is already holding lock:
ffff888028c4eb70 (&q->q_usage_counter(queue)#52){++++}-{0:0}, at: sd_remove+0x8d/0x110 drivers/scsi/sd.c:4072

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&q->q_usage_counter(queue)#52){++++}-{0:0}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       blk_queue_enter+0xe1/0x600 block/blk-core.c:328
       blk_mq_alloc_request+0x26b/0xab0 block/blk-mq.c:626
       scsi_alloc_request drivers/scsi/scsi_lib.c:1222 [inline]
       scsi_execute_cmd+0x177/0x1090 drivers/scsi/scsi_lib.c:304
       read_capacity_10+0x256/0x9c0 drivers/scsi/sd.c:2766
       sd_read_capacity drivers/scsi/sd.c:2834 [inline]
       sd_revalidate_disk+0x106c/0xbcf0 drivers/scsi/sd.c:3734
       sd_probe+0x9fa/0x1100 drivers/scsi/sd.c:4010
       really_probe+0x2b8/0xad0 drivers/base/dd.c:658
       __driver_probe_device+0x1a2/0x390 drivers/base/dd.c:800
       driver_probe_device+0x50/0x430 drivers/base/dd.c:830
       __device_attach_driver+0x2d6/0x530 drivers/base/dd.c:958
       bus_for_each_drv+0x24e/0x2e0 drivers/base/bus.c:459
       __device_attach_async_helper+0x22d/0x300 drivers/base/dd.c:987
       async_run_entry_fn+0xa8/0x420 kernel/async.c:129
       process_one_work kernel/workqueue.c:3229 [inline]
       process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
       worker_thread+0x870/0xd30 kernel/workqueue.c:3391
       kthread+0x2f0/0x390 kernel/kthread.c:389
       ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

-> #2 (&q->limits_lock){+.+.}-{4:4}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       __mutex_lock_common kernel/locking/mutex.c:585 [inline]
       __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735
       queue_limits_start_update include/linux/blkdev.h:940 [inline]
       loop_reconfigure_limits+0x287/0xa70 drivers/block/loop.c:1004
       loop_set_block_size drivers/block/loop.c:1474 [inline]
       lo_simple_ioctl drivers/block/loop.c:1497 [inline]
       lo_ioctl+0x1351/0x1f50 drivers/block/loop.c:1560
       blkdev_ioctl+0x57d/0x6a0 block/ioctl.c:693
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:907 [inline]
       __se_sys_ioctl+0xf9/0x170 fs/ioctl.c:893
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&q->q_usage_counter(io)#17){++++}-{0:0}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       bio_queue_enter block/blk.h:75 [inline]
       blk_mq_submit_bio+0x1510/0x2490 block/blk-mq.c:3069
       __submit_bio+0x2c2/0x560 block/blk-core.c:629
       __submit_bio_noacct_mq block/blk-core.c:710 [inline]
       submit_bio_noacct_nocheck+0x4d3/0xe30 block/blk-core.c:739
       __block_write_full_folio+0x7ed/0xf50 fs/buffer.c:1904
       write_cache_pages+0xd0/0x230 mm/page-writeback.c:2659
       blkdev_writepages+0xb1/0x110 block/fops.c:433
       do_writepages+0x35d/0x870 mm/page-writeback.c:2702
       __writeback_single_inode+0x14f/0x10d0 fs/fs-writeback.c:1656
       writeback_sb_inodes+0x80c/0x1370 fs/fs-writeback.c:1952
       __writeback_inodes_wb+0x11b/0x260 fs/fs-writeback.c:2023
       wb_writeback+0x42f/0xbd0 fs/fs-writeback.c:2134
       wb_check_background_flush fs/fs-writeback.c:2204 [inline]
       wb_do_writeback fs/fs-writeback.c:2292 [inline]
       wb_workfn+0xc58/0x1090 fs/fs-writeback.c:2319
       process_one_work kernel/workqueue.c:3229 [inline]
       process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
       worker_thread+0x870/0xd30 kernel/workqueue.c:3391
       kthread+0x2f0/0x390 kernel/kthread.c:389
       ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

-> #0 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3161 [inline]
       check_prevs_add kernel/locking/lockdep.c:3280 [inline]
       validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
       __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       touch_work_lockdep_map kernel/workqueue.c:3895 [inline]
       start_flush_work kernel/workqueue.c:4149 [inline]
       __flush_work+0x74e/0xc50 kernel/workqueue.c:4181
       flush_work kernel/workqueue.c:4238 [inline]
       flush_delayed_work+0x169/0x1c0 kernel/workqueue.c:4260
       wb_shutdown+0x186/0x1e0 mm/backing-dev.c:575
       bdi_unregister+0x19a/0x5d0 mm/backing-dev.c:1158
       del_gendisk+0x400/0x930 block/genhd.c:707
       sd_remove+0x8d/0x110 drivers/scsi/sd.c:4072
       device_remove drivers/base/dd.c:569 [inline]
       __device_release_driver drivers/base/dd.c:1273 [inline]
       device_release_driver_internal+0x503/0x7c0 drivers/base/dd.c:1296
       bus_remove_device+0x34f/0x420 drivers/base/bus.c:576
       device_del+0x57a/0x9b0 drivers/base/core.c:3861
       __scsi_remove_device+0x1ad/0x3c0 drivers/scsi/scsi_sysfs.c:1499
       scsi_forget_host+0xcf/0x110 drivers/scsi/scsi_scan.c:2068
       scsi_remove_host+0x1dd/0x770 drivers/scsi/hosts.c:181
       quiesce_and_remove_host drivers/usb/storage/usb.c:949 [inline]
       usb_stor_disconnect+0x14e/0x1f0 drivers/usb/storage/usb.c:1178
       usb_unbind_interface+0x25e/0x940 drivers/usb/core/driver.c:461
       device_remove drivers/base/dd.c:569 [inline]
       __device_release_driver drivers/base/dd.c:1273 [inline]
       device_release_driver_internal+0x503/0x7c0 drivers/base/dd.c:1296
       bus_remove_device+0x34f/0x420 drivers/base/bus.c:576
       device_del+0x57a/0x9b0 drivers/base/core.c:3861
       usb_disable_device+0x3bf/0x850 drivers/usb/core/message.c:1418
       usb_disconnect+0x340/0x950 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+0x1ebc/0x5150 drivers/usb/core/hub.c:5903
       process_one_work kernel/workqueue.c:3229 [inline]
       process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
       worker_thread+0x870/0xd30 kernel/workqueue.c:3391
       kthread+0x2f0/0x390 kernel/kthread.c:389
       ret_from_fork+0x4b/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:
  (work_completion)(&(&wb->dwork)->work) --> &q->limits_lock --> &q->q_usage_counter(queue)#52

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&q->q_usage_counter(queue)#52);
                               lock(&q->limits_lock);
                               lock(&q->q_usage_counter(queue)#52);
  lock((work_completion)(&(&wb->dwork)->work));

 *** DEADLOCK ***

9 locks held by kworker/1:5/15509:
 #0: ffff888021e8bd48 ((wq_completion)usb_hub_wq){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3204 [inline]
 #0: ffff888021e8bd48 ((wq_completion)usb_hub_wq){+.+.}-{0:0}, at: process_scheduled_works+0x93b/0x1850 kernel/workqueue.c:3310
 #1: ffffc900048f7d00 ((work_completion)(&hub->events)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3205 [inline]
 #1: ffffc900048f7d00 ((work_completion)(&hub->events)){+.+.}-{0:0}, at: process_scheduled_works+0x976/0x1850 kernel/workqueue.c:3310
 #2: ffff8881443c5190 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #2: ffff8881443c5190 (&dev->mutex){....}-{4:4}, at: hub_event+0x1fe/0x5150 drivers/usb/core/hub.c:5849
 #3: ffff88814d17f190 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #3: ffff88814d17f190 (&dev->mutex){....}-{4:4}, at: usb_disconnect+0x103/0x950 drivers/usb/core/hub.c:2295
 #4: ffff88802484a160 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #4: ffff88802484a160 (&dev->mutex){....}-{4:4}, at: __device_driver_lock drivers/base/dd.c:1095 [inline]
 #4: ffff88802484a160 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0xce/0x7c0 drivers/base/dd.c:1293
 #5: ffff88806d2580e0 (&shost->scan_mutex){+.+.}-{4:4}, at: scsi_remove_host+0x34/0x770 drivers/scsi/hosts.c:169
 #6: ffff88805966c378 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #6: ffff88805966c378 (&dev->mutex){....}-{4:4}, at: __device_driver_lock drivers/base/dd.c:1095 [inline]
 #6: ffff88805966c378 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0xce/0x7c0 drivers/base/dd.c:1293
 #7: ffff888028c4eb70 (&q->q_usage_counter(queue)#52){++++}-{0:0}, at: sd_remove+0x8d/0x110 drivers/scsi/sd.c:4072
 #8: ffffffff8e939ee0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:337 [inline]
 #8: ffffffff8e939ee0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
 #8: ffffffff8e939ee0 (rcu_read_lock){....}-{1:3}, at: start_flush_work kernel/workqueue.c:4123 [inline]
 #8: ffffffff8e939ee0 (rcu_read_lock){....}-{1:3}, at: __flush_work+0xe7/0xc50 kernel/workqueue.c:4181

stack backtrace:
CPU: 1 UID: 0 PID: 15509 Comm: kworker/1:5 Not tainted 6.12.0-rc5-next-20241101-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: usb_hub_wq hub_event
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2074
 check_noncircular+0x36a/0x4a0 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+0x18ef/0x5920 kernel/locking/lockdep.c:3904
 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
 touch_work_lockdep_map kernel/workqueue.c:3895 [inline]
 start_flush_work kernel/workqueue.c:4149 [inline]
 __flush_work+0x74e/0xc50 kernel/workqueue.c:4181
 flush_work kernel/workqueue.c:4238 [inline]
 flush_delayed_work+0x169/0x1c0 kernel/workqueue.c:4260
 wb_shutdown+0x186/0x1e0 mm/backing-dev.c:575
 bdi_unregister+0x19a/0x5d0 mm/backing-dev.c:1158
 del_gendisk+0x400/0x930 block/genhd.c:707
 sd_remove+0x8d/0x110 drivers/scsi/sd.c:4072
 device_remove drivers/base/dd.c:569 [inline]
 __device_release_driver drivers/base/dd.c:1273 [inline]
 device_release_driver_internal+0x503/0x7c0 drivers/base/dd.c:1296
 bus_remove_device+0x34f/0x420 drivers/base/bus.c:576
 device_del+0x57a/0x9b0 drivers/base/core.c:3861
 __scsi_remove_device+0x1ad/0x3c0 drivers/scsi/scsi_sysfs.c:1499
 scsi_forget_host+0xcf/0x110 drivers/scsi/scsi_scan.c:2068
 scsi_remove_host+0x1dd/0x770 drivers/scsi/hosts.c:181
 quiesce_and_remove_host drivers/usb/storage/usb.c:949 [inline]
 usb_stor_disconnect+0x14e/0x1f0 drivers/usb/storage/usb.c:1178
 usb_unbind_interface+0x25e/0x940 drivers/usb/core/driver.c:461
 device_remove drivers/base/dd.c:569 [inline]
 __device_release_driver drivers/base/dd.c:1273 [inline]
 device_release_driver_internal+0x503/0x7c0 drivers/base/dd.c:1296
 bus_remove_device+0x34f/0x420 drivers/base/bus.c:576
 device_del+0x57a/0x9b0 drivers/base/core.c:3861
 usb_disable_device+0x3bf/0x850 drivers/usb/core/message.c:1418
 usb_disconnect+0x340/0x950 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+0x1ebc/0x5150 drivers/usb/core/hub.c:5903
 process_one_work kernel/workqueue.c:3229 [inline]
 process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
 worker_thread+0x870/0xd30 kernel/workqueue.c:3391
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [scsi?] possible deadlock in sd_remove
  2024-11-06  2:29 [syzbot] [scsi?] possible deadlock in sd_remove syzbot
@ 2024-12-31  8:00 ` syzbot
  2025-01-02 10:28   ` Hillf Danton
  2025-01-01  9:20 ` syzbot
  1 sibling, 1 reply; 5+ messages in thread
From: syzbot @ 2024-12-31  8:00 UTC (permalink / raw)
  To: James.Bottomley, james.bottomley, linux-kernel, linux-scsi,
	martin.petersen, syzkaller-bugs

syzbot has found a reproducer for the following issue on:

HEAD commit:    573067a5a685 Merge branch 'for-next/core' into for-kernelci
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=107b88b0580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=cd7202b56d469648
dashboard link: https://syzkaller.appspot.com/bug?extid=566d48f3784973a22771
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14a09818580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/9d3b5c855aa0/disk-573067a5.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/0c06fc1ead83/vmlinux-573067a5.xz
kernel image: https://storage.googleapis.com/syzbot-assets/3390e59b9e4b/Image-573067a5.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+566d48f3784973a22771@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
6.13.0-rc3-syzkaller-g573067a5a685 #0 Not tainted
------------------------------------------------------
kworker/0:3/6486 is trying to acquire lock:
ffff0000eea0a3e0
 (
(work_completion)(&(&wb->dwork)->work)
){+.+.}-{0:0}, at: touch_work_lockdep_map+0x74/0x11c kernel/workqueue.c:3909

but task is already holding lock:
ffff0000c9e931a0 (&q->q_usage_counter(queue)#37){++++}-{0:0}, at: sd_remove+0x8c/0x118 drivers/scsi/sd.c:4072

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&q->q_usage_counter(queue)#37){++++}-{0:0}:
       blk_queue_enter+0xf0/0x538 block/blk-core.c:328
       blk_mq_alloc_request+0x3d8/0x8f0 block/blk-mq.c:652
       scsi_alloc_request drivers/scsi/scsi_lib.c:1222 [inline]
       scsi_execute_cmd+0x144/0xd94 drivers/scsi/scsi_lib.c:304
       read_capacity_10+0x1f4/0x764 drivers/scsi/sd.c:2766
       sd_read_capacity drivers/scsi/sd.c:2834 [inline]
       sd_revalidate_disk+0xd1c/0x98a4 drivers/scsi/sd.c:3734
       sd_probe+0x6f0/0xcec drivers/scsi/sd.c:4010
       really_probe+0x38c/0x8fc drivers/base/dd.c:658
       __driver_probe_device+0x194/0x374 drivers/base/dd.c:800
       driver_probe_device+0x78/0x330 drivers/base/dd.c:830
       __device_attach_driver+0x2a8/0x4f4 drivers/base/dd.c:958
       bus_for_each_drv+0x228/0x2bc drivers/base/bus.c:459
       __device_attach_async_helper+0x210/0x2c0 drivers/base/dd.c:987
       async_run_entry_fn+0x98/0x3b4 kernel/async.c:129
       process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
       process_scheduled_works kernel/workqueue.c:3310 [inline]
       worker_thread+0x97c/0xeec kernel/workqueue.c:3391
       kthread+0x288/0x310 kernel/kthread.c:389
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862

-> #2 (&q->limits_lock){+.+.}-{4:4}:
       __mutex_lock_common+0x218/0x28f4 kernel/locking/mutex.c:585
       __mutex_lock kernel/locking/mutex.c:735 [inline]
       mutex_lock_nested+0x2c/0x38 kernel/locking/mutex.c:787
       queue_limits_start_update include/linux/blkdev.h:947 [inline]
       nvme_update_ns_info_block+0x5b4/0x2848 drivers/nvme/host/core.c:2185
       nvme_update_ns_info+0xdc/0xed0
       nvme_alloc_ns drivers/nvme/host/core.c:3897 [inline]
       nvme_scan_ns+0x2028/0x36ec drivers/nvme/host/core.c:4071
       nvme_scan_ns_sequential+0x198/0x250 drivers/nvme/host/core.c:4186
       nvme_scan_work+0x9e0/0xd18 drivers/nvme/host/core.c:4247
       process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
       process_scheduled_works kernel/workqueue.c:3310 [inline]
       worker_thread+0x97c/0xeec kernel/workqueue.c:3391
       kthread+0x288/0x310 kernel/kthread.c:389
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862

-> #1 (&q->q_usage_counter(io)#50){++++}-{0:0}:
       bio_queue_enter block/blk.h:75 [inline]
       blk_mq_submit_bio+0x1254/0x2070 block/blk-mq.c:3090
       __submit_bio+0x1a0/0x4f8 block/blk-core.c:629
       __submit_bio_noacct_mq block/blk-core.c:710 [inline]
       submit_bio_noacct_nocheck+0x3bc/0xcbc block/blk-core.c:739
       submit_bio_noacct+0xc6c/0x166c block/blk-core.c:868
       submit_bio+0x374/0x564 block/blk-core.c:910
       submit_bh_wbc+0x3f8/0x4c8 fs/buffer.c:2814
       __block_write_full_folio+0x840/0xd74 fs/buffer.c:1904
       block_write_full_folio+0x2fc/0x3c4
       write_cache_pages+0xc8/0x20c mm/page-writeback.c:2659
       blkdev_writepages+0xac/0x100 block/fops.c:433
       do_writepages+0x304/0x7d0 mm/page-writeback.c:2702
       __writeback_single_inode+0x15c/0x15a4 fs/fs-writeback.c:1680
       writeback_sb_inodes+0x650/0x1088 fs/fs-writeback.c:1976
       __writeback_inodes_wb+0xec/0x234 fs/fs-writeback.c:2047
       wb_writeback+0x3f4/0xe9c fs/fs-writeback.c:2158
       wb_check_background_flush fs/fs-writeback.c:2228 [inline]
       wb_do_writeback fs/fs-writeback.c:2316 [inline]
       wb_workfn+0xc28/0x1048 fs/fs-writeback.c:2343
       process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
       process_scheduled_works kernel/workqueue.c:3310 [inline]
       worker_thread+0x97c/0xeec kernel/workqueue.c:3391
       kthread+0x288/0x310 kernel/kthread.c:389
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862

-> #0 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}:
       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+0x34f0/0x7904 kernel/locking/lockdep.c:5226
       lock_acquire+0x23c/0x724 kernel/locking/lockdep.c:5849
       touch_work_lockdep_map+0x9c/0x11c kernel/workqueue.c:3909
       start_flush_work kernel/workqueue.c:4163 [inline]
       __flush_work+0x578/0x954 kernel/workqueue.c:4195
       flush_work kernel/workqueue.c:4252 [inline]
       flush_delayed_work+0xcc/0xf8 kernel/workqueue.c:4274
       wb_shutdown+0x154/0x1d0 mm/backing-dev.c:575
       bdi_unregister+0x160/0x4f8 mm/backing-dev.c:1158
       del_gendisk+0x39c/0x870 block/genhd.c:707
       sd_remove+0x8c/0x118 drivers/scsi/sd.c:4072
       device_remove drivers/base/dd.c:569 [inline]
       __device_release_driver drivers/base/dd.c:1273 [inline]
       device_release_driver_internal+0x440/0x698 drivers/base/dd.c:1296
       device_release_driver+0x28/0x38 drivers/base/dd.c:1319
       bus_remove_device+0x314/0x3b4 drivers/base/bus.c:576
       device_del+0x480/0x828 drivers/base/core.c:3854
       __scsi_remove_device+0x178/0x368 drivers/scsi/scsi_sysfs.c:1499
       scsi_forget_host+0xe0/0x128 drivers/scsi/scsi_scan.c:2068
       scsi_remove_host+0x13c/0x6c8 drivers/scsi/hosts.c:181
       quiesce_and_remove_host drivers/usb/storage/usb.c:949 [inline]
       usb_stor_disconnect+0x13c/0x218 drivers/usb/storage/usb.c:1178
       usb_unbind_interface+0x22c/0x7ec drivers/usb/core/driver.c:458
       device_remove drivers/base/dd.c:569 [inline]
       __device_release_driver drivers/base/dd.c:1273 [inline]
       device_release_driver_internal+0x440/0x698 drivers/base/dd.c:1296
       device_release_driver+0x28/0x38 drivers/base/dd.c:1319
       bus_remove_device+0x314/0x3b4 drivers/base/bus.c:576
       device_del+0x480/0x828 drivers/base/core.c:3854
       usb_disable_device+0x354/0x760 drivers/usb/core/message.c:1418
       usb_disconnect+0x290/0x808 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+0x1918/0x4280 drivers/usb/core/hub.c:5903
       process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
       process_scheduled_works kernel/workqueue.c:3310 [inline]
       worker_thread+0x97c/0xeec kernel/workqueue.c:3391
       kthread+0x288/0x310 kernel/kthread.c:389
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862

other info that might help us debug this:

Chain exists of:
  (work_completion)(&(&wb->dwork)->work) --> &q->limits_lock --> &q->q_usage_counter(queue)#37

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&q->q_usage_counter(queue)#37);
                               lock(&q->limits_lock);
                               lock(&q->q_usage_counter(queue)#37);
  lock((work_completion)(&(&wb->dwork)->work));

 *** DEADLOCK ***

9 locks held by kworker/0:3/6486:
 #0: ffff0000c27b6148 ((wq_completion)usb_hub_wq){+.+.}-{0:0}, at: process_one_work+0x60c/0x15cc kernel/workqueue.c:3203
 #1: ffff8000a44e7c20 ((work_completion)(&hub->events)){+.+.}-{0:0}, at: process_one_work+0x6a4/0x15cc kernel/workqueue.c:3203
 #2: ffff0000cd047190 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #2: ffff0000cd047190 (&dev->mutex){....}-{4:4}, at: hub_event+0x1bc/0x4280 drivers/usb/core/hub.c:5849
 #3: ffff0000ecb7d190 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #3: ffff0000ecb7d190 (&dev->mutex){....}-{4:4}, at: usb_disconnect+0xec/0x808 drivers/usb/core/hub.c:2295
 #4: ffff0000c2c25160 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #4: ffff0000c2c25160 (&dev->mutex){....}-{4:4}, at: __device_driver_lock drivers/base/dd.c:1095 [inline]
 #4: ffff0000c2c25160 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0xbc/0x698 drivers/base/dd.c:1293
 #5: ffff0000c7af80e0 (&shost->scan_mutex){+.+.}-{4:4}, at: scsi_remove_host+0x44/0x6c8 drivers/scsi/hosts.c:169
 #6: ffff0000c88a4378 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #6: ffff0000c88a4378 (&dev->mutex){....}-{4:4}, at: __device_driver_lock drivers/base/dd.c:1095 [inline]
 #6: ffff0000c88a4378 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0xbc/0x698 drivers/base/dd.c:1293
 #7: ffff0000c9e931a0 (&q->q_usage_counter(queue)#37){++++}-{0:0}, at: sd_remove+0x8c/0x118 drivers/scsi/sd.c:4072
 #8: ffff80008fb82560 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x10/0x4c include/linux/rcupdate.h:336

stack backtrace:
CPU: 0 UID: 0 PID: 6486 Comm: kworker/0:3 Not tainted 6.13.0-rc3-syzkaller-g573067a5a685 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: usb_hub_wq hub_event
Call trace:
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:466 (C)
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:120
 dump_stack+0x1c/0x28 lib/dump_stack.c:129
 print_circular_bug+0x154/0x1c0 kernel/locking/lockdep.c:2074
 check_noncircular+0x310/0x404 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+0x34f0/0x7904 kernel/locking/lockdep.c:5226
 lock_acquire+0x23c/0x724 kernel/locking/lockdep.c:5849
 touch_work_lockdep_map+0x9c/0x11c kernel/workqueue.c:3909
 start_flush_work kernel/workqueue.c:4163 [inline]
 __flush_work+0x578/0x954 kernel/workqueue.c:4195
 flush_work kernel/workqueue.c:4252 [inline]
 flush_delayed_work+0xcc/0xf8 kernel/workqueue.c:4274
 wb_shutdown+0x154/0x1d0 mm/backing-dev.c:575
 bdi_unregister+0x160/0x4f8 mm/backing-dev.c:1158
 del_gendisk+0x39c/0x870 block/genhd.c:707
 sd_remove+0x8c/0x118 drivers/scsi/sd.c:4072
 device_remove drivers/base/dd.c:569 [inline]
 __device_release_driver drivers/base/dd.c:1273 [inline]
 device_release_driver_internal+0x440/0x698 drivers/base/dd.c:1296
 device_release_driver+0x28/0x38 drivers/base/dd.c:1319
 bus_remove_device+0x314/0x3b4 drivers/base/bus.c:576
 device_del+0x480/0x828 drivers/base/core.c:3854
 __scsi_remove_device+0x178/0x368 drivers/scsi/scsi_sysfs.c:1499
 scsi_forget_host+0xe0/0x128 drivers/scsi/scsi_scan.c:2068
 scsi_remove_host+0x13c/0x6c8 drivers/scsi/hosts.c:181
 quiesce_and_remove_host drivers/usb/storage/usb.c:949 [inline]
 usb_stor_disconnect+0x13c/0x218 drivers/usb/storage/usb.c:1178
 usb_unbind_interface+0x22c/0x7ec drivers/usb/core/driver.c:458
 device_remove drivers/base/dd.c:569 [inline]
 __device_release_driver drivers/base/dd.c:1273 [inline]
 device_release_driver_internal+0x440/0x698 drivers/base/dd.c:1296
 device_release_driver+0x28/0x38 drivers/base/dd.c:1319
 bus_remove_device+0x314/0x3b4 drivers/base/bus.c:576
 device_del+0x480/0x828 drivers/base/core.c:3854
 usb_disable_device+0x354/0x760 drivers/usb/core/message.c:1418
 usb_disconnect+0x290/0x808 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+0x1918/0x4280 drivers/usb/core/hub.c:5903
 process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
 process_scheduled_works kernel/workqueue.c:3310 [inline]
 worker_thread+0x97c/0xeec kernel/workqueue.c:3391
 kthread+0x288/0x310 kernel/kthread.c:389
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [scsi?] possible deadlock in sd_remove
  2024-11-06  2:29 [syzbot] [scsi?] possible deadlock in sd_remove syzbot
  2024-12-31  8:00 ` syzbot
@ 2025-01-01  9:20 ` syzbot
  1 sibling, 0 replies; 5+ messages in thread
From: syzbot @ 2025-01-01  9:20 UTC (permalink / raw)
  To: James.Bottomley, james.bottomley, linux-kernel, linux-scsi,
	martin.petersen, syzkaller-bugs

syzbot has found a reproducer for the following issue on:

HEAD commit:    573067a5a685 Merge branch 'for-next/core' into for-kernelci
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=156f28b0580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=cd7202b56d469648
dashboard link: https://syzkaller.appspot.com/bug?extid=566d48f3784973a22771
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=148656df980000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=143dd818580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/9d3b5c855aa0/disk-573067a5.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/0c06fc1ead83/vmlinux-573067a5.xz
kernel image: https://storage.googleapis.com/syzbot-assets/3390e59b9e4b/Image-573067a5.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+566d48f3784973a22771@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
6.13.0-rc3-syzkaller-g573067a5a685 #0 Not tainted
------------------------------------------------------
kworker/1:2/2269 is trying to acquire lock:
ffff0000dfbc03e0 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: touch_work_lockdep_map+0x74/0x11c kernel/workqueue.c:3909

but task is already holding lock:
ffff0000cad4e260 (&q->q_usage_counter(queue)#37){++++}-{0:0}, at: sd_remove+0x8c/0x118 drivers/scsi/sd.c:4072

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&q->q_usage_counter(queue)#37){++++}-{0:0}:
       blk_queue_enter+0xf0/0x538 block/blk-core.c:328
       blk_mq_alloc_request+0x3d8/0x8f0 block/blk-mq.c:652
       scsi_alloc_request drivers/scsi/scsi_lib.c:1222 [inline]
       scsi_execute_cmd+0x144/0xd94 drivers/scsi/scsi_lib.c:304
       read_capacity_10+0x1f4/0x764 drivers/scsi/sd.c:2766
       sd_read_capacity drivers/scsi/sd.c:2834 [inline]
       sd_revalidate_disk+0xd1c/0x98a4 drivers/scsi/sd.c:3734
       sd_probe+0x6f0/0xcec drivers/scsi/sd.c:4010
       really_probe+0x38c/0x8fc drivers/base/dd.c:658
       __driver_probe_device+0x194/0x374 drivers/base/dd.c:800
       driver_probe_device+0x78/0x330 drivers/base/dd.c:830
       __device_attach_driver+0x2a8/0x4f4 drivers/base/dd.c:958
       bus_for_each_drv+0x228/0x2bc drivers/base/bus.c:459
       __device_attach_async_helper+0x210/0x2c0 drivers/base/dd.c:987
       async_run_entry_fn+0x98/0x3b4 kernel/async.c:129
       process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
       process_scheduled_works kernel/workqueue.c:3310 [inline]
       worker_thread+0x97c/0xeec kernel/workqueue.c:3391
       kthread+0x288/0x310 kernel/kthread.c:389
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862

-> #2 (&q->limits_lock){+.+.}-{4:4}:
       __mutex_lock_common+0x218/0x28f4 kernel/locking/mutex.c:585
       __mutex_lock kernel/locking/mutex.c:735 [inline]
       mutex_lock_nested+0x2c/0x38 kernel/locking/mutex.c:787
       queue_limits_start_update include/linux/blkdev.h:947 [inline]
       nvme_update_ns_info_block+0x5b4/0x2848 drivers/nvme/host/core.c:2185
       nvme_update_ns_info+0xdc/0xed0
       nvme_alloc_ns drivers/nvme/host/core.c:3897 [inline]
       nvme_scan_ns+0x2028/0x36ec drivers/nvme/host/core.c:4071
       nvme_scan_ns_sequential+0x198/0x250 drivers/nvme/host/core.c:4186
       nvme_scan_work+0x9e0/0xd18 drivers/nvme/host/core.c:4247
       process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
       process_scheduled_works kernel/workqueue.c:3310 [inline]
       worker_thread+0x97c/0xeec kernel/workqueue.c:3391
       kthread+0x288/0x310 kernel/kthread.c:389
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862

-> #1 (&q->q_usage_counter(io)#50){++++}-{0:0}:
       bio_queue_enter block/blk.h:75 [inline]
       blk_mq_submit_bio+0x1254/0x2070 block/blk-mq.c:3090
       __submit_bio+0x1a0/0x4f8 block/blk-core.c:629
       __submit_bio_noacct_mq block/blk-core.c:710 [inline]
       submit_bio_noacct_nocheck+0x3bc/0xcbc block/blk-core.c:739
       submit_bio_noacct+0xc6c/0x166c block/blk-core.c:868
       submit_bio+0x374/0x564 block/blk-core.c:910
       submit_bh_wbc+0x3f8/0x4c8 fs/buffer.c:2814
       __block_write_full_folio+0x840/0xd74 fs/buffer.c:1904
       block_write_full_folio+0x2fc/0x3c4
       write_cache_pages+0xc8/0x20c mm/page-writeback.c:2659
       blkdev_writepages+0xac/0x100 block/fops.c:433
       do_writepages+0x304/0x7d0 mm/page-writeback.c:2702
       __writeback_single_inode+0x15c/0x15a4 fs/fs-writeback.c:1680
       writeback_sb_inodes+0x650/0x1088 fs/fs-writeback.c:1976
       __writeback_inodes_wb+0xec/0x234 fs/fs-writeback.c:2047
       wb_writeback+0x3f4/0xe9c fs/fs-writeback.c:2158
       wb_check_background_flush fs/fs-writeback.c:2228 [inline]
       wb_do_writeback fs/fs-writeback.c:2316 [inline]
       wb_workfn+0xc28/0x1048 fs/fs-writeback.c:2343
       process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
       process_scheduled_works kernel/workqueue.c:3310 [inline]
       worker_thread+0x97c/0xeec kernel/workqueue.c:3391
       kthread+0x288/0x310 kernel/kthread.c:389
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862

-> #0 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}:
       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+0x34f0/0x7904 kernel/locking/lockdep.c:5226
       lock_acquire+0x23c/0x724 kernel/locking/lockdep.c:5849
       touch_work_lockdep_map+0x9c/0x11c kernel/workqueue.c:3909
       start_flush_work kernel/workqueue.c:4163 [inline]
       __flush_work+0x578/0x954 kernel/workqueue.c:4195
       flush_work kernel/workqueue.c:4252 [inline]
       flush_delayed_work+0xcc/0xf8 kernel/workqueue.c:4274
       wb_shutdown+0x154/0x1d0 mm/backing-dev.c:575
       bdi_unregister+0x160/0x4f8 mm/backing-dev.c:1158
       del_gendisk+0x39c/0x870 block/genhd.c:707
       sd_remove+0x8c/0x118 drivers/scsi/sd.c:4072
       device_remove drivers/base/dd.c:569 [inline]
       __device_release_driver drivers/base/dd.c:1273 [inline]
       device_release_driver_internal+0x440/0x698 drivers/base/dd.c:1296
       device_release_driver+0x28/0x38 drivers/base/dd.c:1319
       bus_remove_device+0x314/0x3b4 drivers/base/bus.c:576
       device_del+0x480/0x828 drivers/base/core.c:3854
       __scsi_remove_device+0x178/0x368 drivers/scsi/scsi_sysfs.c:1499
       scsi_forget_host+0xe0/0x128 drivers/scsi/scsi_scan.c:2068
       scsi_remove_host+0x13c/0x6c8 drivers/scsi/hosts.c:181
       quiesce_and_remove_host drivers/usb/storage/usb.c:949 [inline]
       usb_stor_disconnect+0x13c/0x218 drivers/usb/storage/usb.c:1178
       usb_unbind_interface+0x22c/0x7ec drivers/usb/core/driver.c:458
       device_remove drivers/base/dd.c:569 [inline]
       __device_release_driver drivers/base/dd.c:1273 [inline]
       device_release_driver_internal+0x440/0x698 drivers/base/dd.c:1296
       device_release_driver+0x28/0x38 drivers/base/dd.c:1319
       bus_remove_device+0x314/0x3b4 drivers/base/bus.c:576
       device_del+0x480/0x828 drivers/base/core.c:3854
       usb_disable_device+0x354/0x760 drivers/usb/core/message.c:1418
       usb_disconnect+0x290/0x808 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+0x1918/0x4280 drivers/usb/core/hub.c:5903
       process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
       process_scheduled_works kernel/workqueue.c:3310 [inline]
       worker_thread+0x97c/0xeec kernel/workqueue.c:3391
       kthread+0x288/0x310 kernel/kthread.c:389
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862

other info that might help us debug this:

Chain exists of:
  (work_completion)(&(&wb->dwork)->work) --> &q->limits_lock --> &q->q_usage_counter(queue)#37

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&q->q_usage_counter(queue)#37);
                               lock(&q->limits_lock);
                               lock(&q->q_usage_counter(queue)#37);
  lock((work_completion)(&(&wb->dwork)->work));

 *** DEADLOCK ***

9 locks held by kworker/1:2/2269:
 #0: ffff0000c2772148 ((wq_completion)usb_hub_wq){+.+.}-{0:0}, at: process_one_work+0x60c/0x15cc kernel/workqueue.c:3203
 #1: ffff8000a0a67c20 ((work_completion)(&hub->events)){+.+.}-{0:0}, at: process_one_work+0x6a4/0x15cc kernel/workqueue.c:3203
 #2: ffff0000cca1d190 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #2: ffff0000cca1d190 (&dev->mutex){....}-{4:4}, at: hub_event+0x1bc/0x4280 drivers/usb/core/hub.c:5849
 #3: ffff0000dfae4190 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #3: ffff0000dfae4190 (&dev->mutex){....}-{4:4}, at: usb_disconnect+0xec/0x808 drivers/usb/core/hub.c:2295
 #4: ffff0000d8cc5160 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #4: ffff0000d8cc5160 (&dev->mutex){....}-{4:4}, at: __device_driver_lock drivers/base/dd.c:1095 [inline]
 #4: ffff0000d8cc5160 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0xbc/0x698 drivers/base/dd.c:1293
 #5: ffff0000df90c0e0 (&shost->scan_mutex){+.+.}-{4:4}, at: scsi_remove_host+0x44/0x6c8 drivers/scsi/hosts.c:169
 #6: ffff0000c72d6378 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1014 [inline]
 #6: ffff0000c72d6378 (&dev->mutex){....}-{4:4}, at: __device_driver_lock drivers/base/dd.c:1095 [inline]
 #6: ffff0000c72d6378 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0xbc/0x698 drivers/base/dd.c:1293
 #7: ffff0000cad4e260 (&q->q_usage_counter(queue)#37){++++}-{0:0}, at: sd_remove+0x8c/0x118 drivers/scsi/sd.c:4072
 #8: ffff80008fb82560 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x10/0x4c include/linux/rcupdate.h:336

stack backtrace:
CPU: 1 UID: 0 PID: 2269 Comm: kworker/1:2 Not tainted 6.13.0-rc3-syzkaller-g573067a5a685 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: usb_hub_wq hub_event
Call trace:
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:466 (C)
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:120
 dump_stack+0x1c/0x28 lib/dump_stack.c:129
 print_circular_bug+0x154/0x1c0 kernel/locking/lockdep.c:2074
 check_noncircular+0x310/0x404 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+0x34f0/0x7904 kernel/locking/lockdep.c:5226
 lock_acquire+0x23c/0x724 kernel/locking/lockdep.c:5849
 touch_work_lockdep_map+0x9c/0x11c kernel/workqueue.c:3909
 start_flush_work kernel/workqueue.c:4163 [inline]
 __flush_work+0x578/0x954 kernel/workqueue.c:4195
 flush_work kernel/workqueue.c:4252 [inline]
 flush_delayed_work+0xcc/0xf8 kernel/workqueue.c:4274
 wb_shutdown+0x154/0x1d0 mm/backing-dev.c:575
 bdi_unregister+0x160/0x4f8 mm/backing-dev.c:1158
 del_gendisk+0x39c/0x870 block/genhd.c:707
 sd_remove+0x8c/0x118 drivers/scsi/sd.c:4072
 device_remove drivers/base/dd.c:569 [inline]
 __device_release_driver drivers/base/dd.c:1273 [inline]
 device_release_driver_internal+0x440/0x698 drivers/base/dd.c:1296
 device_release_driver+0x28/0x38 drivers/base/dd.c:1319
 bus_remove_device+0x314/0x3b4 drivers/base/bus.c:576
 device_del+0x480/0x828 drivers/base/core.c:3854
 __scsi_remove_device+0x178/0x368 drivers/scsi/scsi_sysfs.c:1499
 scsi_forget_host+0xe0/0x128 drivers/scsi/scsi_scan.c:2068
 scsi_remove_host+0x13c/0x6c8 drivers/scsi/hosts.c:181
 quiesce_and_remove_host drivers/usb/storage/usb.c:949 [inline]
 usb_stor_disconnect+0x13c/0x218 drivers/usb/storage/usb.c:1178
 usb_unbind_interface+0x22c/0x7ec drivers/usb/core/driver.c:458
 device_remove drivers/base/dd.c:569 [inline]
 __device_release_driver drivers/base/dd.c:1273 [inline]
 device_release_driver_internal+0x440/0x698 drivers/base/dd.c:1296
 device_release_driver+0x28/0x38 drivers/base/dd.c:1319
 bus_remove_device+0x314/0x3b4 drivers/base/bus.c:576
 device_del+0x480/0x828 drivers/base/core.c:3854
 usb_disable_device+0x354/0x760 drivers/usb/core/message.c:1418
 usb_disconnect+0x290/0x808 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+0x1918/0x4280 drivers/usb/core/hub.c:5903
 process_one_work+0x7a8/0x15cc kernel/workqueue.c:3229
 process_scheduled_works kernel/workqueue.c:3310 [inline]
 worker_thread+0x97c/0xeec kernel/workqueue.c:3391
 kthread+0x288/0x310 kernel/kthread.c:389
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [scsi?] possible deadlock in sd_remove
  2024-12-31  8:00 ` syzbot
@ 2025-01-02 10:28   ` Hillf Danton
  2025-01-02 10:41     ` syzbot
  0 siblings, 1 reply; 5+ messages in thread
From: Hillf Danton @ 2025-01-02 10:28 UTC (permalink / raw)
  To: syzbot; +Cc: linux-kernel, linux-scsi, Ming Lei, linux-block, syzkaller-bugs

On Tue, 31 Dec 2024 00:00:20 -0800
> syzbot has found a reproducer for the following issue on:
> 
> HEAD commit:    573067a5a685 Merge branch 'for-next/core' into for-kernelci
> git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14a09818580000

#syz test: https://github.com/ming1/linux v6.13/block-fix

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [scsi?] possible deadlock in sd_remove
  2025-01-02 10:28   ` Hillf Danton
@ 2025-01-02 10:41     ` syzbot
  0 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2025-01-02 10:41 UTC (permalink / raw)
  To: hdanton, linux-block, linux-kernel, linux-scsi, ming.lei,
	syzkaller-bugs

Hello,

syzbot tried to test the proposed patch but the build/boot failed:

block/blk.h:728:7: error: use of undeclared identifier 'queue_dying'; did you mean 'cpu_dying'?
block/partitions/../blk.h:728:7: error: use of undeclared identifier 'queue_dying'; did you mean 'cpu_dying'?
block/partitions/../blk.h:734:7: error: use of undeclared identifier 'queue_dying'; did you mean 'cpu_dying'?
block/blk.h:734:7: error: use of undeclared identifier 'queue_dying'; did you mean 'cpu_dying'?
kernel/trace/../../block/blk.h:728:7: error: use of undeclared identifier 'queue_dying'; did you mean 'cpu_dying'?
kernel/trace/../../block/blk.h:734:7: error: use of undeclared identifier 'queue_dying'; did you mean 'cpu_dying'?


Tested on:

commit:         cbacbf06 block: track queue dying state automatically ..
git tree:       https://github.com/ming1/linux v6.13/block-fix
kernel config:  https://syzkaller.appspot.com/x/.config?x=cd7202b56d469648
dashboard link: https://syzkaller.appspot.com/bug?extid=566d48f3784973a22771
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64

Note: no patches were applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-02 10:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-06  2:29 [syzbot] [scsi?] possible deadlock in sd_remove syzbot
2024-12-31  8:00 ` syzbot
2025-01-02 10:28   ` Hillf Danton
2025-01-02 10:41     ` syzbot
2025-01-01  9:20 ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox