possible deadlock in chunk_size_store

Status: upstream: reported on 2026/08/13 17:16
Reported-by: syzbot+d4c2bcb9a66acc0731c4@syzkaller.appspotmail.com
First crash: 106d, last: 15h24m

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.8.2531/17120 is trying to acquire lock:
ffff88801c9982c0 (&mddev->reconfig_mutex){+.+.}-{3:3}, at: mddev_lock drivers/md/md.h:543 [inline]
ffff88801c9982c0 (&mddev->reconfig_mutex){+.+.}-{3:3}, at: chunk_size_store+0xb6/0x430 drivers/md/md.c:4321

but task is already holding lock:
ffff888062b172c0 (kn->active#792){++++}-{0:0}, at: kernfs_fop_write_iter+0x1fd/0x500 fs/kernfs/file.c:288

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (kn->active#792){++++}-{0:0}:
       kernfs_drain fs/kernfs/dir.c:478 [inline]
       __kernfs_remove+0x5da/0xcb0 fs/kernfs/dir.c:1372
       kernfs_remove+0x1d/0x30 fs/kernfs/dir.c:1406
       __kobject_del+0xe0/0x2e0 lib/kobject.c:628
       kobject_del+0x41/0x60 lib/kobject.c:651
       mddev_delayed_delete+0x27/0x30 drivers/md/md.c:5697
       process_one_work+0x867/0xff0 kernel/workqueue.c:2310
       worker_thread+0xad7/0x12a0 kernel/workqueue.c:2457
       kthread+0x42e/0x520 kernel/kthread.c:334
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

-> #2 ((work_completion)(&mddev->del_work)){+.+.}-{0:0}:
       process_one_work+0x7ba/0xff0 kernel/workqueue.c:2286
       worker_thread+0xad7/0x12a0 kernel/workqueue.c:2457
       kthread+0x42e/0x520 kernel/kthread.c:334
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

-> #1 ((wq_completion)md_misc){+.+.}-{0:0}:
       flush_workqueue+0x16a/0x1390 kernel/workqueue.c:2830
       __md_stop+0x190/0x2f0 drivers/md/md.c:6362
       md_stop+0x7a/0xe0 drivers/md/md.c:6382
       raid_dtr+0x4b/0x60 drivers/md/dm-raid.c:3323
       dm_table_destroy+0x185/0x420 drivers/md/dm-table.c:195
       dm_hash_remove_all+0x10e/0x200 drivers/md/dm-ioctl.c:350
       remove_all+0x4c/0xa0 drivers/md/dm-ioctl.c:514
       ctl_ioctl drivers/md/dm-ioctl.c:2032 [inline]
       dm_ctl_ioctl+0x947/0xd00 drivers/md/dm-ioctl.c:2054
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (&mddev->reconfig_mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3125 [inline]
       check_prevs_add kernel/locking/lockdep.c:3244 [inline]
       validate_chain kernel/locking/lockdep.c:3860 [inline]
       __lock_acquire+0x39b7/0x7e20 kernel/locking/lockdep.c:5134
       lock_acquire+0x19f/0x400 kernel/locking/lockdep.c:5751
       __mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_interruptible_nested+0x17/0x20 kernel/locking/mutex.c:765
       mddev_lock drivers/md/md.h:543 [inline]
       chunk_size_store+0xb6/0x430 drivers/md/md.c:4321
       md_attr_store+0xdd/0x130 drivers/md/md.c:5654
       kernfs_fop_write_iter+0x3a8/0x500 fs/kernfs/file.c:296
       call_write_iter include/linux/fs.h:2181 [inline]
       new_sync_write fs/read_write.c:507 [inline]
       vfs_write+0x748/0xd70 fs/read_write.c:594
       ksys_write+0x153/0x260 fs/read_write.c:647
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

other info that might help us debug this:

Chain exists of:
  &mddev->reconfig_mutex --> (work_completion)(&mddev->del_work) --> kn->active#792

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(kn->active#792);
                               lock((work_completion)(&mddev->del_work));
                               lock(kn->active#792);
  lock(&mddev->reconfig_mutex);

 *** DEADLOCK ***

4 locks held by syz.8.2531/17120:
 #0: ffff888060dae0f0 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2bf/0x370 fs/file.c:1056
 #1: ffff888021c04460 (sb_writers#8){.+.+}-{0:0}, at: vfs_write+0x296/0xd70 fs/read_write.c:590
 #2: ffff888061605c88 (&of->mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0x1dc/0x500 fs/kernfs/file.c:287
 #3: ffff888062b172c0 (kn->active#792){++++}-{0:0}, at: kernfs_fop_write_iter+0x1fd/0x500 fs/kernfs/file.c:288

stack backtrace:
CPU: 1 PID: 17120 Comm: syz.8.2531 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106
 check_noncircular+0x2f8/0x400 kernel/locking/lockdep.c:2178
 check_prev_add kernel/locking/lockdep.c:3125 [inline]
 check_prevs_add kernel/locking/lockdep.c:3244 [inline]
 validate_chain kernel/locking/lockdep.c:3860 [inline]
 __lock_acquire+0x39b7/0x7e20 kernel/locking/lockdep.c:5134
 lock_acquire+0x19f/0x400 kernel/locking/lockdep.c:5751
 __mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_interruptible_nested+0x17/0x20 kernel/locking/mutex.c:765
 mddev_lock drivers/md/md.h:543 [inline]
 chunk_size_store+0xb6/0x430 drivers/md/md.c:4321
 md_attr_store+0xdd/0x130 drivers/md/md.c:5654
 kernfs_fop_write_iter+0x3a8/0x500 fs/kernfs/file.c:296
 call_write_iter include/linux/fs.h:2181 [inline]
 new_sync_write fs/read_write.c:507 [inline]
 vfs_write+0x748/0xd70 fs/read_write.c:594
 ksys_write+0x153/0x260 fs/read_write.c:647
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fcf59e7ea99
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:00007fcf580cb028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fcf5a10afa0 RCX: 00007fcf59e7ea99
RDX: 0000000000000004 RSI: 0000200000000180 RDI: 0000000000000004
RBP: 00007fcf59f0e18b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fcf5a10b038 R14: 00007fcf5a10afa0 R15: 00007ffe059bf348
 </TASK>
bridge0: toggle option: 5 state: 0 -> 1
bridge0: bond_netdev_event received NETDEV_CHANGE
net bridge0: siw: event 4
kcov: kcov_task_exit: t = ffff88802b0a1dc0, kcov->t = ffff88802b0a1dc0

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/27 02:13 linux-5.15.y 4f2df9a01754 f1f6b8bf .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in chunk_size_store
2026/11/26 05:24 linux-5.15.y 4f2df9a01754 9a575fe5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in chunk_size_store
2026/11/18 10:08 linux-5.15.y 29c6cdaac04a eb4895d7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in chunk_size_store
2026/08/23 20:43 linux-5.15.y 945fa863f02c 1e72964b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in chunk_size_store
2026/08/13 17:15 linux-5.15.y aabd761612db 359b2492 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in chunk_size_store
* Struck through repros no longer work on HEAD.