From: syzbot <syzbot+9e3014263a35700ab49b@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] md: validate raid_disks against MD_SB_DISKS in super_90_load
Date: Sun, 13 Sep 2026 20:52:39 -0700 [thread overview]
Message-ID: <6aa76f87.016ef6ab.da411.0007.GAE@google.com> (raw)
In-Reply-To: <6aa6a091.f670cee1.72fc4.0012.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] md: validate raid_disks against MD_SB_DISKS in super_90_load
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
The v0.90 superblock format can only describe MD_SB_DISKS (27) member
disks, but super_90_load() only checks that sb->raid_disks is
positive, not that it fits within this limit.
A crafted/corrupt superblock with an oversized raid_disks value is
accepted and copied into mddev->raid_disks. When the superblock is
later rewritten (e.g. via a write to the rdev 'state' sysfs
attribute), super_90_sync() uses this value to index sb->disks[],
causing an out-of-bounds array access:
UBSAN: array-index-out-of-bounds in drivers/md/md.c:1697:17
index 124 is out of range for type 'mdp_disk_t [27]'
Reject superblocks whose raid_disks value cannot be represented by
the v0.90 format at load time, before it is trusted anywhere else.
Reported-by: syzbot+9e3014263a35700ab49b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=9e3014263a35700ab49b
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
drivers/md/md.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 680b34a63cb3..c65da77677bc 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1393,7 +1393,8 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
goto abort;
}
- if (sb->raid_disks <= 0)
+ if (sb->raid_disks <= 0 ||
+ sb->raid_disks > MD_SB_DISKS)
goto abort;
if (md_csum_fold(calc_sb_csum(sb)) != md_csum_fold(sb->sb_csum)) {
--
2.34.1
next prev parent reply other threads:[~2026-09-14 3:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 13:09 [syzbot] [raid?] UBSAN: array-index-out-of-bounds in super_90_sync syzbot
2026-09-13 17:34 ` syzbot
2026-09-14 3:52 ` syzbot [this message]
2026-09-14 4:22 ` Forwarded: [PATCH] md: fix out-of-bounds access to superblock disk array syzbot
2026-09-14 7:44 ` Forwarded: [PATCH] configfs: unhash dentry before dropping the item syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6aa76f87.016ef6ab.da411.0007.GAE@google.com \
--to=syzbot+9e3014263a35700ab49b@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®