[v5.15] possible deadlock in bd_register_pending_holders (2)

0 views
Skip to first unread message

syzbot

unread,
Apr 14, 2024, 9:52:23 PMApr 14
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: fa3df276cd36 Linux 5.15.155
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=150ad74d180000
kernel config: https://syzkaller.appspot.com/x/.config?x=f12ea3f162537c9c
dashboard link: https://syzkaller.appspot.com/bug?extid=26fd30d0b4ec26be61f2
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/feaf3fb3f68f/disk-fa3df276.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/537c519f1dd0/vmlinux-fa3df276.xz
kernel image: https://storage.googleapis.com/syzbot-assets/5396ec75d1be/bzImage-fa3df276.xz

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

======================================================
WARNING: possible circular locking dependency detected
5.15.155-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/15977 is trying to acquire lock:
ffff8880610e9918 (&disk->open_mutex){+.+.}-{3:3}, at: bd_register_pending_holders+0x33/0x320 block/holder.c:161

but task is already holding lock:
ffffffff8d745fc8 (disks_mutex){+.+.}-{3:3}, at: md_alloc+0x3e/0xd40 drivers/md/md.c:5723

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #9 (disks_mutex){+.+.}-{3:3}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
md_alloc+0x3e/0xd40 drivers/md/md.c:5723
blk_request_module+0x181/0x1a0 block/genhd.c:687
blkdev_get_no_open+0x39/0x190 block/bdev.c:740
blkdev_get_by_dev+0x89/0xa50 block/bdev.c:804
swsusp_check+0xb1/0x2c0 kernel/power/swap.c:1526
software_resume+0xc6/0x3c0 kernel/power/hibernate.c:977
resume_store+0xe3/0x130 kernel/power/hibernate.c:1179
kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2172 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0xacf/0xe50 fs/read_write.c:594
ksys_write+0x1a2/0x2c0 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #8 (major_names_lock){+.+.}-{3:3}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
blk_request_module+0x2f/0x1a0 block/genhd.c:684
blkdev_get_no_open+0x39/0x190 block/bdev.c:740
blkdev_get_by_dev+0x89/0xa50 block/bdev.c:804
swsusp_check+0xb1/0x2c0 kernel/power/swap.c:1526
software_resume+0xc6/0x3c0 kernel/power/hibernate.c:977
resume_store+0xe3/0x130 kernel/power/hibernate.c:1179
kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2172 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0xacf/0xe50 fs/read_write.c:594
ksys_write+0x1a2/0x2c0 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #7 (system_transition_mutex/1){+.+.}-{3:3}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
software_resume+0x7c/0x3c0 kernel/power/hibernate.c:932
resume_store+0xe3/0x130 kernel/power/hibernate.c:1179
kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2172 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0xacf/0xe50 fs/read_write.c:594
ksys_write+0x1a2/0x2c0 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #6 (&of->mutex){+.+.}-{3:3}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
kernfs_seq_start+0x50/0x3b0 fs/kernfs/file.c:112
seq_read_iter+0x3d0/0xd10 fs/seq_file.c:225
call_read_iter include/linux/fs.h:2166 [inline]
new_sync_read fs/read_write.c:404 [inline]
vfs_read+0xa9f/0xe10 fs/read_write.c:485
ksys_read+0x1a2/0x2c0 fs/read_write.c:623
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #5 (&p->lock){+.+.}-{3:3}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
seq_read_iter+0xae/0xd10 fs/seq_file.c:182
call_read_iter include/linux/fs.h:2166 [inline]
generic_file_splice_read+0x4ad/0x790 fs/splice.c:311
do_splice_to fs/splice.c:796 [inline]
splice_direct_to_actor+0x448/0xc10 fs/splice.c:870
do_splice_direct+0x285/0x3d0 fs/splice.c:979
do_sendfile+0x625/0xff0 fs/read_write.c:1249
__do_sys_sendfile64 fs/read_write.c:1317 [inline]
__se_sys_sendfile64+0x178/0x1e0 fs/read_write.c:1303
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #4 (sb_writers#3){.+.+}-{0:0}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
__sb_start_write include/linux/fs.h:1811 [inline]
sb_start_write include/linux/fs.h:1881 [inline]
file_start_write include/linux/fs.h:3037 [inline]
lo_write_bvec+0x1a3/0x740 drivers/block/loop.c:315
lo_write_simple drivers/block/loop.c:338 [inline]
do_req_filebacked drivers/block/loop.c:656 [inline]
loop_handle_cmd drivers/block/loop.c:2234 [inline]
loop_process_work+0x2309/0x2af0 drivers/block/loop.c:2274
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:300

-> #3 ((work_completion)(&worker->work)){+.+.}-{0:0}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
process_one_work+0x7f1/0x10c0 kernel/workqueue.c:2286
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:300

-> #2 ((null)){+.+.}-{0:0}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
flush_workqueue+0x170/0x1610 kernel/workqueue.c:2830
drain_workqueue+0xc5/0x390 kernel/workqueue.c:2995
destroy_workqueue+0x7b/0xae0 kernel/workqueue.c:4439
__loop_clr_fd+0x241/0xbe0 drivers/block/loop.c:1383
blkdev_put_whole block/bdev.c:692 [inline]
blkdev_put+0x455/0x790 block/bdev.c:954
btrfs_close_bdev fs/btrfs/volumes.c:1153 [inline]
btrfs_close_one_device fs/btrfs/volumes.c:1174 [inline]
close_fs_devices+0x45e/0x8e0 fs/btrfs/volumes.c:1217
btrfs_close_devices+0xc4/0x5c0 fs/btrfs/volumes.c:1232
close_ctree+0x731/0x890 fs/btrfs/disk-io.c:4518
generic_shutdown_super+0x136/0x2c0 fs/super.c:475
kill_anon_super+0x37/0x60 fs/super.c:1076
btrfs_kill_super+0x3d/0x50 fs/btrfs/super.c:2391
deactivate_locked_super+0xa0/0x110 fs/super.c:335
cleanup_mnt+0x44e/0x500 fs/namespace.c:1143
task_work_run+0x129/0x1a0 kernel/task_work.c:164
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
__syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307
do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #1 (&lo->lo_mutex){+.+.}-{3:3}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_killable_nested+0x17/0x20 kernel/locking/mutex.c:758
lo_open+0x68/0x100 drivers/block/loop.c:2055
blkdev_get_whole+0x94/0x390 block/bdev.c:669
blkdev_get_by_dev+0x2bc/0xa50 block/bdev.c:824
blkdev_open+0x138/0x2d0 block/fops.c:463
do_dentry_open+0x807/0xfb0 fs/open.c:826
do_open fs/namei.c:3608 [inline]
path_openat+0x2705/0x2f20 fs/namei.c:3742
do_filp_open+0x21c/0x460 fs/namei.c:3769
do_sys_openat2+0x13b/0x500 fs/open.c:1253
do_sys_open fs/open.c:1269 [inline]
__do_sys_openat fs/open.c:1285 [inline]
__se_sys_openat fs/open.c:1280 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1280
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (&disk->open_mutex){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
bd_register_pending_holders+0x33/0x320 block/holder.c:161
device_add_disk+0x5b9/0xd60 block/genhd.c:486
add_disk include/linux/genhd.h:203 [inline]
md_alloc+0x8ad/0xd40 drivers/md/md.c:5782
blk_request_module+0x181/0x1a0 block/genhd.c:687
blkdev_get_no_open+0x39/0x190 block/bdev.c:740
blkdev_get_by_dev+0x89/0xa50 block/bdev.c:804
swsusp_check+0xb1/0x2c0 kernel/power/swap.c:1526
software_resume+0xc6/0x3c0 kernel/power/hibernate.c:977
resume_store+0xe3/0x130 kernel/power/hibernate.c:1179
kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2172 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0xacf/0xe50 fs/read_write.c:594
ksys_write+0x1a2/0x2c0 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

other info that might help us debug this:

Chain exists of:
&disk->open_mutex --> major_names_lock --> disks_mutex

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(disks_mutex);
lock(major_names_lock);
lock(disks_mutex);
lock(&disk->open_mutex);

*** DEADLOCK ***

7 locks held by syz-executor.0/15977:
#0: ffff88802423c0f0 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2cb/0x380 fs/file.c:1088
#1: ffff88807f018460 (sb_writers#8){.+.+}-{0:0}, at: vfs_write+0x29a/0xe50 fs/read_write.c:590
#2: ffff88805f707488 (&of->mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0x1e7/0x4f0 fs/kernfs/file.c:287
#3: ffff888144bbd008 (kn->active#813){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x20b/0x4f0 fs/kernfs/file.c:288
#4: ffffffff8c7d8548 (system_transition_mutex/1){+.+.}-{3:3}, at: software_resume+0x7c/0x3c0 kernel/power/hibernate.c:932
#5: ffffffff8cef77e8 (major_names_lock){+.+.}-{3:3}, at: blk_request_module+0x2f/0x1a0 block/genhd.c:684
#6: ffffffff8d745fc8 (disks_mutex){+.+.}-{3:3}, at: md_alloc+0x3e/0xd40 drivers/md/md.c:5723

stack backtrace:
CPU: 0 PID: 15977 Comm: syz-executor.0 Not tainted 5.15.155-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
check_noncircular+0x2f8/0x3b0 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
bd_register_pending_holders+0x33/0x320 block/holder.c:161
device_add_disk+0x5b9/0xd60 block/genhd.c:486
add_disk include/linux/genhd.h:203 [inline]
md_alloc+0x8ad/0xd40 drivers/md/md.c:5782
blk_request_module+0x181/0x1a0 block/genhd.c:687
blkdev_get_no_open+0x39/0x190 block/bdev.c:740
blkdev_get_by_dev+0x89/0xa50 block/bdev.c:804
swsusp_check+0xb1/0x2c0 kernel/power/swap.c:1526
software_resume+0xc6/0x3c0 kernel/power/hibernate.c:977
resume_store+0xe3/0x130 kernel/power/hibernate.c:1179
kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2172 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0xacf/0xe50 fs/read_write.c:594
ksys_write+0x1a2/0x2c0 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f1f8e6e8e69
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f1f8cc5b0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f1f8e816f80 RCX: 00007f1f8e6e8e69
RDX: 0000000000000012 RSI: 0000000020000000 RDI: 0000000000000005
RBP: 00007f1f8e73547a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f1f8e816f80 R15: 00007ffc732123f8
</TASK>
PM: Image not found (code -6)


---
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 syzk...@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
Reply all
Reply to author
Forward
0 new messages