syzbot
possible deadlock in md_alloc
Status:
upstream: reported C repro on 2026/10/31 09:26
Subsystems:
block
Labels:
prio:low
[Documentation on labels]
Reported-by: syzbot+cd254889291ef8666036@syzkaller.appspotmail.com
First crash: 4d02h, last: 2h50m
✨ AI-generated root cause summary:
A circular locking dependency exists between major_names_lock, md's internal disks_mutex, and mddev->reconfig_mutex. In blk_probe_dev(), major_names_lock is held while invoking the driver's autoload probe callback md_probe(), which calls md_alloc() and acquires disks_mutex followed by mddev->reconfig_mutex. Concurrently, md ioctls (such as ADD_NEW_DISK) hold mddev->reconfig_mutex while calling bdev_file_open_by_dev(), which triggers block device autoloading and attempts to acquire major_names_lock via blk_request_module() / blk_probe_dev(), resulting in a potential ABBA deadlock.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
A circular locking dependency (potential deadlock) exists between major_names_lock (in block/genhd.c), disks_mutex (in drivers/md/md.c), and &mddev->reconfig_mutex (in drivers/md/md.c).
The Circular Dependency Chain
-
disks_mutex $\rightarrow$ &mddev->reconfig_mutex:
In drivers/md/md.c:md_alloc() (e.g., invoked when creating an md array via /sys/module/md_mod/parameters/new_array $\rightarrow$ add_named_array() $\rightarrow$ md_alloc_and_put()):
-
&mddev->reconfig_mutex $\rightarrow$ major_names_lock:
In drivers/md/md.c:md_ioctl():
- When executing ioctl operations like
ADD_NEW_DISK or HOT_ADD_DISK, mddev_lock(mddev) is held (drivers/md/md.c:8426), holding &mddev->reconfig_mutex.
- In
md_add_new_disk(), the kernel calls md_import_device(dev, ...) (drivers/md/md.c:7681).
md_import_device() calls bdev_file_open_by_dev() (drivers/md/md.c:3861).
bdev_file_open_by_dev() calls blkdev_get_no_open(dev, true) (block/bdev.c:1091).
- With legacy block device autoloading enabled (
CONFIG_BLOCK_LEGACY_AUTOLOAD), blkdev_get_no_open() calls blk_request_module() (block/bdev.c:870), which in turn calls blk_probe_dev() (block/genhd.c:901).
blk_probe_dev() acquires mutex_lock(&major_names_lock) (block/genhd.c:885).
-
major_names_lock $\rightarrow$ disks_mutex:
When an unopened block device node is opened via userspace (sys_openat $\rightarrow$ blkdev_open() $\rightarrow$ blkdev_get_no_open(dev, true)):
blk_request_module() calls blk_probe_dev() (block/genhd.c:885).
blk_probe_dev() acquires mutex_lock(&major_names_lock) and iterates over major_names.
- While still holding
major_names_lock, it invokes the driver's registered .probe callback ((*n)->probe(devt)) (block/genhd.c:888).
- For MD devices, this calls
md_probe() (drivers/md/md.c:6463).
- When
create_on_open is true (default), md_probe() calls md_alloc_and_put(), which calls md_alloc().
md_alloc() calls mutex_lock(&disks_mutex) (drivers/md/md.c:6355).
Consequence in a Production Kernel
In a production kernel without lockdep, if one thread runs an ioctl(ADD_NEW_DISK) on an existing array (holding &mddev->reconfig_mutex and attempting to acquire major_names_lock during component device probe/open), and a concurrent thread accesses/opens an MD device node (holding major_names_lock in blk_probe_dev() and attempting to acquire disks_mutex or &mddev->reconfig_mutex), both threads will deadlock, hanging all subsequent block device probing and MD administration indefinitely.
Classification
- RootCauseFiles:
block/genhd.c, drivers/md/md.c
- MemoryCorruption:
false (locking order violation causing deadlocks; no memory safety violation or corrupted pointers)
- InfoLeak:
"none" (no kernel memory disclosure to userspace)
- RawDenialOfService:
true (mutual deadlock between kernel threads resulting in indefinite hanging of tasks and block device subsystem operations)
- IsNetCandidate:
false (block layer / md raid subsystem)
- IsKVMCandidate:
false (not KVM / virtualization related)
▶
▼
Last patch testing requests (1)
Sample crash report:
md: could not open device unknown-block(8,200).
md: error, md_import_device() returned -6
md: could not open device unknown-block(8,250).
md: error, md_import_device() returned -6
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz-executor140/6002 is trying to acquire lock:
ffffffff91329200 (disks_mutex){+.+.}-{4:4}, at: md_alloc+0x40/0xf40 drivers/md/md.c:6355
but task is already holding lock:
ffffffff9096c060 (major_names_lock){+.+.}-{4:4}, at: blk_probe_dev block/genhd.c:885 [inline]
ffffffff9096c060 (major_names_lock){+.+.}-{4:4}, at: blk_request_module+0x35/0x2a0 block/genhd.c:901
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (major_names_lock){+.+.}-{4:4}:
__mutex_lock_common kernel/locking/mutex.c:646 [inline]
__mutex_lock+0x197/0x15a0 kernel/locking/mutex.c:821
blk_probe_dev block/genhd.c:885 [inline]
blk_request_module+0x35/0x2a0 block/genhd.c:901
blkdev_get_no_open+0x3f/0xe0 block/bdev.c:870
bdev_file_open_by_dev+0xa0/0x240 block/bdev.c:1091
md_import_device+0x2e9/0x650 drivers/md/md.c:3861
md_add_new_disk+0x522/0x1850 drivers/md/md.c:7681
md_ioctl+0x2027/0x2630 drivers/md/md.c:8525
blkdev_ioctl+0x5e3/0x740 block/ioctl.c:798
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
-> #1 (&mddev->reconfig_mutex){+.+.}-{4:4}:
__mutex_lock_common kernel/locking/mutex.c:646 [inline]
__mutex_lock+0x197/0x15a0 kernel/locking/mutex.c:821
mddev_lock_nointr drivers/md/md.h:734 [inline]
md_alloc+0x81e/0xf40 drivers/md/md.c:6413
md_alloc_and_put+0x1a/0x1f0 drivers/md/md.c:6452
add_named_array+0x240/0x350 drivers/md/md.c:-1
param_attr_store+0x214/0x310 kernel/params.c:591
module_attr_store+0x65/0x90 kernel/params.c:906
kernfs_fop_write_iter+0x3a4/0x540 fs/kernfs/file.c:345
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x612/0xba0 fs/read_write.c:687
ksys_write+0x150/0x270 fs/read_write.c:1036
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
-> #0 (disks_mutex){+.+.}-{4:4}:
check_prev_add kernel/locking/lockdep.c:3209 [inline]
check_prevs_add kernel/locking/lockdep.c:3328 [inline]
validate_chain kernel/locking/lockdep.c:3952 [inline]
__lock_acquire+0x164c/0x2de0 kernel/locking/lockdep.c:5288
lock_acquire+0x115/0x350 kernel/locking/lockdep.c:5942
__mutex_lock_common kernel/locking/mutex.c:646 [inline]
__mutex_lock+0x197/0x15a0 kernel/locking/mutex.c:821
md_alloc+0x40/0xf40 drivers/md/md.c:6355
md_alloc_and_put+0x1a/0x1f0 drivers/md/md.c:6452
blk_probe_dev block/genhd.c:888 [inline]
blk_request_module+0x27d/0x2a0 block/genhd.c:-1
blkdev_get_no_open+0x3f/0xe0 block/bdev.c:870
blkdev_open+0x1d7/0x600 block/fops.c:678
do_dentry_open+0x80e/0x1360 fs/open.c:1000
vfs_open_consume+0x4a/0x350 fs/open.c:1131
do_open fs/namei.c:4845 [inline]
path_openat+0x16fc/0x20f0 fs/namei.c:5010
do_file_open+0x23e/0x4a0 fs/namei.c:5039
do_sys_openat2+0x115/0x200 fs/open.c:1442
do_sys_open fs/open.c:1448 [inline]
__do_sys_openat fs/open.c:1788 [inline]
__se_sys_openat fs/open.c:1783 [inline]
__x64_sys_openat+0x138/0x170 fs/open.c:1783
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
other info that might help us debug this:
Chain exists of:
disks_mutex --> &mddev->reconfig_mutex --> major_names_lock
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(major_names_lock);
lock(&mddev->reconfig_mutex);
lock(major_names_lock);
lock(disks_mutex);
*** DEADLOCK ***
locks held by syz-executor140/6002: 1, last CPU#1:
#0: ffffffff9096c060 (major_names_lock){+.+.}-{4:4}, at: blk_probe_dev block/genhd.c:885 [inline]
#0: ffffffff9096c060 (major_names_lock){+.+.}-{4:4}, at: blk_request_module+0x35/0x2a0 block/genhd.c:901
stack backtrace:
CPU: 1 UID: 0 PID: 6002 Comm: syz-executor140 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/07/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_circular_bug+0x2e2/0x300 kernel/locking/lockdep.c:2087
check_noncircular+0x12f/0x150 kernel/locking/lockdep.c:2219
check_prev_add kernel/locking/lockdep.c:3209 [inline]
check_prevs_add kernel/locking/lockdep.c:3328 [inline]
validate_chain kernel/locking/lockdep.c:3952 [inline]
__lock_acquire+0x164c/0x2de0 kernel/locking/lockdep.c:5288
lock_acquire+0x115/0x350 kernel/locking/lockdep.c:5942
__mutex_lock_common kernel/locking/mutex.c:646 [inline]
__mutex_lock+0x197/0x15a0 kernel/locking/mutex.c:821
md_alloc+0x40/0xf40 drivers/md/md.c:6355
md_alloc_and_put+0x1a/0x1f0 drivers/md/md.c:6452
blk_probe_dev block/genhd.c:888 [inline]
blk_request_module+0x27d/0x2a0 block/genhd.c:-1
blkdev_get_no_open+0x3f/0xe0 block/bdev.c:870
blkdev_open+0x1d7/0x600 block/fops.c:678
do_dentry_open+0x80e/0x1360 fs/open.c:1000
vfs_open_consume+0x4a/0x350 fs/open.c:1131
do_open fs/namei.c:4845 [inline]
path_openat+0x16fc/0x20f0 fs/namei.c:5010
do_file_open+0x23e/0x4a0 fs/namei.c:5039
do_sys_openat2+0x115/0x200 fs/open.c:1442
do_sys_open fs/open.c:1448 [inline]
__do_sys_openat fs/open.c:1788 [inline]
__se_sys_openat fs/open.c:1783 [inline]
__x64_sys_openat+0x138/0x170 fs/open.c:1783
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f9cb93efb37
Code: 48 89 fa 4c 89 df e8 98 1d 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
RSP: 002b:00007ffd0a7a14d0 EFLAGS: 00000202 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 000055558698d400 RCX: 00007f9cb93efb37
RDX: 0000000000000002 RSI: 00007ffd0a7a15f0 RDI: ffffffffffffff9c
RBP: 00007ffd0a7a15b0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 00007ffd0a7a15f0
R13: 00000000ffffffff R14: 00007f9cb942909a R15: 0000000000000002
</TASK>
md: async del_gendisk mode will be removed in future, please upgrade to mdadm-4.5+
block device autoloading is deprecated and will be removed.
md: async del_gendisk mode will be removed in future, please upgrade to mdadm-4.5+
block device autoloading is deprecated and will be removed.
* Struck through repros no longer work on HEAD.