Skip to contentSkip to conversation

UBSAN: shift-out-of-bounds in raid5_set_limits

syzbot syzbot 1 participant 2 messages Aug 8 – Aug 9 MD RAID

lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following issue on:

HEAD commit:    7235a3e71949 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=169f0e49580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=ccf4bea59f67007
dashboard link: https://syzkaller.appspot.com/bug?extid=de94ddbfff0c9e6fe030
compiler:       Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=143b0132580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=114717b9580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/fd45635beaae/disk-7235a3e7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d7d2e6507223/vmlinux-7235a3e7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b5b5d8de4cea/Image-7235a3e7.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

md/raid:md0: not clean -- starting background reconstruction md/raid:md0: device ram0 operational as raid disk 0 md/raid:md0: raid level 5 active with 1 out of 1 devices, algorithm 0

------------[ cut here ]------------
UBSAN: shift-out-of-bounds in ./include/linux/log2.h:57:13
shift exponent 64 is too large for 64-bit type 'unsigned long'
CPU: 0 UID: 0 PID: 4920 Comm: syz.0.18 Not tainted syzkaller #0 PREEMPT 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/02/2026
Call trace:
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:499 (C)
 __dump_stack+0x30/0x40 lib/dump_stack.c:94
 dump_stack_lvl+0xd8/0x12c lib/dump_stack.c:120
 dump_stack+0x1c/0x28 lib/dump_stack.c:129
 ubsan_epilogue+0x14/0x48 lib/ubsan.c:233
 __ubsan_handle_shift_out_of_bounds+0x224/0x264 lib/ubsan.c:494
 __roundup_pow_of_two include/linux/log2.h:57 [inline]
 raid5_set_limits+0x470/0x510 drivers/md/raid5.c:7835
 raid5_run+0x1554/0x1b68 drivers/md/raid5.c:8133
 md_run+0xb9c/0x1a6c drivers/md/md.c:6760
 do_md_run+0x4c/0x4e4 drivers/md/md.c:6861
 array_state_store+0x7a8/0xce8 drivers/md/md.c:-1
 md_attr_store+0x304/0x438 drivers/md/md.c:6137
 sysfs_kf_write+0xe0/0x108 fs/sysfs/file.c:145
 kernfs_fop_write_iter+0x260/0x3b8 fs/kernfs/file.c:345
 new_sync_write fs/read_write.c:595 [inline]
 vfs_write+0x51c/0xa0c fs/read_write.c:687
 ksys_write+0x12c/0x228 fs/read_write.c:739
 __do_sys_write fs/read_write.c:750 [inline]
 __se_sys_write fs/read_write.c:747 [inline]
 __arm64_sys_write+0x84/0x98 fs/read_write.c:747
 __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+0x64/0x260 arch/arm64/kernel/entry-common.c:736
 el0t_64_sync_handler+0x48/0x148 arch/arm64/kernel/entry-common.c:755
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:594
---[ end trace ]---

---
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 [email protected].

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 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.

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

author syzbot
#1 lore raw

Forwarded: [PATCH] md: enforce minimum of 2 disks for raid 4 and 5

For archival purposes, forwarding an incoming command email to [email protected].

For archival purposes, forwarding an incoming command email to [email protected].

***

Subject: [PATCH] md: enforce minimum of 2 disks for raid 4 and 5
Author: [email protected]

#syz test

---
 drivers/md/raid5.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/raid5.c +6 -0
index ffb5fcde54a9..e02c579d4ceb 100644
@@ -7541,6 +7541,12 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 			mdname(mddev), mddev->new_layout);
 		return ERR_PTR(-EIO);
 	}
+	if ((mddev->new_level == 4 || mddev->new_level == 5)
+	    && mddev->raid_disks < 2) {
+		pr_warn("md/raid:%s: not enough configured devices (%d, minimum 2)\n",
+			mdname(mddev), mddev->raid_disks);
+		return ERR_PTR(-EINVAL);
+	}
 	if (mddev->new_level == 6 && mddev->raid_disks < 4) {
 		pr_warn("md/raid:%s: not enough configured devices (%d, minimum 4)\n",
 			mdname(mddev), mddev->raid_disks);
Signature · 1 line
2.55.0