WARNING in mempool_init_node (2)

Status: moderation: reported on 2026/12/06 10:20
Subsystems: raid
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+aaa893ff1154cc7ce764@syzkaller.appspotmail.com
First crash: 49m, last: 49m
✨ AI cause bisection: introduced by (AI job) :
commit c2968285925adb97b9aa4ede94c1f1ab61ce0925
Author: Xiao Ni <xni@redhat.com>
Date: Thu Feb 4 07:50:44 2021 +0000

  md/raid10: extend r10bio devs to raid disks

✨ AI-generated root cause summary:

md_set_array_info() and sysfs raid_disks_store() accept arbitrary values for mddev->raid_disks without enforcing an upper bound (for non-persistent arrays mddev->max_disks is 0 and is not checked before pers->run()). During RAID10 initialization in setup_conf(), allocating conf->mirrors (24 bytes per disk) succeeds for raid_disks values up to 174,762 (<= KMALLOC_MAX_SIZE of 4 MiB), after which create_r10bio_pool() calls mempool_create_kmalloc_pool() with calc_r10bio_size(raid_disks) = 72 + raid_disks * 32 bytes. For raid_disks >= 131,071 (such as 131,075, yielding 0x4000a8 bytes as seen in register x19), the per-element size exceeds KMALLOC_MAX_SIZE, triggering WARN_ON_ONCE_GFP(size > KMALLOC_MAX_SIZE, flags) in ___kmalloc_large_node().

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 9c9253b2eda8:

Root Cause

The warning in ___kmalloc_large_node() (mm/slub.c:5459) is caused by missing upper-bound validation on mddev->raid_disks in MD array configuration (drivers/md/md.c) and RAID10 configuration setup (drivers/md/raid10.c), allowing an oversized kmalloc() request (> KMALLOC_MAX_SIZE) to be issued when creating r10conf->r10bio_pool.

Detailed Mechanism

  1. Unbounded mddev->raid_disks configuration (drivers/md/md.c):

    • In md_set_array_info() (reachable via md_ioctl() with SET_ARRAY_INFO -> __md_set_array_info()), when info->raid_disks != 0, mddev->raid_disks = info->raid_disks; is assigned directly without validating any upper bound (or checking against mddev->max_disks, which is only set to MD_SB_DISKS when mddev->persistent is true and remains 0 for non-persistent arrays).
    • Similarly, raid_disks_store() in sysfs writes mddev->raid_disks = n; without an upper bound check when !mddev->pers (and super_1_validate() assigns mddev->raid_disks = le32_to_cpu(sb->raid_disks) without checking against mddev->max_disks).
  2. Allocation size exceeding KMALLOC_MAX_SIZE (drivers/md/raid10.c):

    • When md_ioctl(RUN_ARRAY) -> do_md_run() -> md_run() invokes raid10_run(), setup_conf() is called before raid10_run() checks enough(conf, -1) (so only at least one device in mddev->disks is needed to pass the list_empty(&mddev->disks) check in md_run()).
    • setup_conf() calls setup_geo(&geo, mddev, geo_new), which copies mddev->raid_disks into geo.raid_disks, and only checks copies < 2 || copies > mddev->raid_disks (which passes for any large raid_disks with a valid copies >= 2).
    • setup_conf() then allocates conf->mirrors via kzalloc_objs(struct raid10_info, mddev->raid_disks + max(0, -mddev->delta_disks)). Because sizeof(struct raid10_info) is 24 bytes and KMALLOC_MAX_SIZE is 1UL << (MAX_PAGE_ORDER + PAGE_SHIFT) = 4 MiB (0x400000 bytes with 4 KiB pages and MAX_PAGE_ORDER == 10), this allocation succeeds for raid_disks up to 174762.
    • Next, setup_conf() calls create_r10bio_pool(conf->geo.raid_disks), which computes:
      calc_r10bio_size(raid_disks) = offsetof(struct r10bio, devs[raid_disks])
      
      where devs is at offset 72 bytes in struct r10bio and sizeof(struct r10dev) is 32 bytes.
    • For raid_disks >= 131071 (in this report, raid_disks = 131075, producing 72 + 131075 * 32 = 4194472 = 0x4000a8, matching register x19 in ___kmalloc_large_node), calc_r10bio_size() exceeds KMALLOC_MAX_SIZE.
    • create_r10bio_pool() passes this size to mempool_create_kmalloc_pool(NR_RAID_BIOS, size) -> mempool_create_node_noprof() -> mempool_init_node() -> mempool_kmalloc() -> ___kmalloc_large_node(), triggering WARN_ON_ONCE_GFP(size > KMALLOC_MAX_SIZE, flags).
  3. Additional notes on related paths:

    • Note that calc_r10bio_size() returns int rather than size_t (though in setup_conf(), conf->mirrors allocation fails kmalloc before raid_disks is large enough to overflow int).
    • A similar pattern exists in raid10_start_reshape() when mddev->delta_disks > 0 (create_r10bio_pool(new.raid_disks)), as well as in drivers/md/raid1.c (setup_conf() / raid1_reshape() sizing struct r1bio with bios[raid_disks * 2]) if mddev->raid_disks is not bounded.

Potential Fix Direction

Enforce a sensible upper limit on mddev->raid_disks (and raid_disks in md_set_array_info() / raid_disks_store() / super_1_validate()), and/or validate in raid10.c setup_conf() (and raid10_start_reshape()) that raid_disks and calc_r10bio_size(raid_disks) (using size_t / struct_size()) do not exceed KMALLOC_MAX_SIZE (or a RAID10 disk maximum) before calling kzalloc_objs() or create_r10bio_pool().

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
c9985a58 bisect-cause IsRelease: ❌ ❓ WARNING in mempool_init_node (2) 2026/12/06 10:16 2026/12/06 10:16 2026/12/06 10:24 3a4d724d
b083ec64 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ WARNING in mempool_init_node (2) 2026/12/06 10:15 2026/12/06 10:15 2026/12/06 10:19 3a4d724d
▶ ▼ Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream WARNING in mempool_init_node block -1 1 921d 917d 0/30 auto-obsoleted due to no activity on 2024/09/06 04:16

Sample crash report:
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.
------------[ cut here ]------------
WARNING: mm/slub.c:5459 at ___kmalloc_large_node+0x15c/0x194 mm/slub.c:5459, CPU#1: syz.5.219/6104
Modules linked in:
CPU: 1 UID: 0 PID: 6104 Comm: syz.5.219 Not tainted syzkaller #0 PREEMPT 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
pstate: 23400005 (nzCv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : ___kmalloc_large_node+0x15c/0x194 mm/slub.c:5459
lr : __kmalloc_large_node_noprof+0x2c/0x8c mm/slub.c:5502
sp : ffff800097d47390
x29: ffff800097d47390 x28: 1fffe0001bb6b608 x27: dfff800000000000
x26: ffff8000809a8e9c x25: 1fffe0001bb6b60a x24: ffff0000ddb5b040
x23: 0000000000000100 x22: 00000000ffffffff x21: 0000000000000cc0
x20: 0000000000000cc0 x19: 00000000004000a8 x18: ffff8001235c3000
x17: ffff0001ace733c7 x16: ffff0000cd6a8014 x15: ffff800080d65820
x14: 0000000000000001 x13: 0000000000000001 x12: 0000000000000003
x11: 0000000000000000 x10: 0000000000000003 x9 : 0000000000000001
x8 : ffff80008af8d000 x7 : 0000000000000000 x6 : ffff800080166ad0
x5 : 00000000ffffffff x4 : 0000000000000cc0 x3 : ffff8000809a7204
x2 : 00000000ffffffff x1 : 0000000000000cc0 x0 : 0000000000000000
Call trace:
 ___kmalloc_large_node+0x15c/0x194 mm/slub.c:5459 (P)
 __kmalloc_large_node_noprof+0x2c/0x8c mm/slub.c:5502
 __do_kmalloc_node mm/slub.c:5519 [inline]
 __kmalloc_noprof+0x3f0/0x6c8 mm/slub.c:5556
 _kmalloc_noprof include/linux/slab.h:995 [inline]
 mempool_kmalloc+0x28/0x38 mm/mempool.c:746
 mempool_init_node+0x1c0/0x484 mm/mempool.c:272
 mempool_create_node_noprof+0xc8/0x154 mm/mempool.c:336
 create_r10bio_pool drivers/md/raid10.c:115 [inline]
 setup_conf+0x1f8/0x820 drivers/md/raid10.c:3831
 raid10_run+0x16c/0x1300 drivers/md/raid10.c:3920
 md_run+0xb10/0x19e8 drivers/md/md.c:6808
 do_md_run+0x4c/0x4e4 drivers/md/md.c:6909
 md_ioctl+0x1c08/0x23e4 drivers/md/md.c:8541
 blkdev_ioctl+0x574/0x904 block/ioctl.c:795
 vfs_ioctl fs/ioctl.c:52 [inline]
 __do_sys_ioctl fs/ioctl.c:598 [inline]
 __se_sys_ioctl fs/ioctl.c:584 [inline]
 __arm64_sys_ioctl+0x154/0x1cc fs/ioctl.c:584
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606
irq event stamp: 1674
hardirqs last  enabled at (1673): [<ffff8000869b3a10>] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:210 [inline]
hardirqs last  enabled at (1673): [<ffff8000869b3a10>] _raw_spin_unlock_irqrestore+0x38/0x98 kernel/locking/spinlock.c:221
hardirqs last disabled at (1674): [<ffff80008698d5e0>] el1_brk64+0x20/0x54 arch/arm64/kernel/entry-common.c:484
softirqs last  enabled at (1594): [<ffff80008013ab20>] local_bh_enable include/linux/bottom_half.h:33 [inline]
softirqs last  enabled at (1594): [<ffff80008013ab20>] put_cpu_fpsimd_context arch/arm64/kernel/fpsimd.c:251 [inline]
softirqs last  enabled at (1594): [<ffff80008013ab20>] fpsimd_restore_current_state+0x39c/0x9c8 arch/arm64/kernel/fpsimd.c:1780
softirqs last disabled at (1592): [<ffff80008013a7c8>] local_bh_disable include/linux/bottom_half.h:20 [inline]
softirqs last disabled at (1592): [<ffff80008013a7c8>] get_cpu_fpsimd_context arch/arm64/kernel/fpsimd.c:234 [inline]
softirqs last disabled at (1592): [<ffff80008013a7c8>] fpsimd_restore_current_state+0x44/0x9c8 arch/arm64/kernel/fpsimd.c:1773
---[ end trace 0000000000000000 ]---
md: pers->run() failed ...

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/12/06 10:08 https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 9c9253b2eda8 3a4d724d .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 WARNING in mempool_init_node
* Struck through repros no longer work on HEAD.