Linux RAID subsystem development
 help / color / mirror / Atom feed
From: Aaditya Kansal <aadityakansal390@gmail.com>
To: syzbot+9e3014263a35700ab49b@syzkaller.appspotmail.com
Cc: linux-raid@vger.kernel.org, Aaditya Kansal <aadityakansal390@gmail.com>
Subject: [PATCH] md: add max_disks bound check in older version
Date: Mon, 14 Sep 2026 05:14:38 +0530	[thread overview]
Message-ID: <20260913234627.465492-1-aadityakansal390@gmail.com> (raw)
In-Reply-To: <6aa6deac.f670cee1.72fc4.0013.GAE@google.com>

#syz test

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 680b34a63cb3..f5fce41637f1 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1693,6 +1693,12 @@ static void super_90_sync(struct mddev *mddev, struct md_rdev *rdev)
 			desc_nr = rdev2->raid_disk;
 		else
 			desc_nr = next_spare++;
+
+		if (desc_nr >= MD_SB_DISKS) {
+			pr_warn("md: raid_disks = %d exceeds max_disks = %d for version 0.90\n",
+					desc_nr, MD_SB_DISKS);
+			continue;
+		}
 		rdev2->desc_nr = desc_nr;
 		d = &sb->disks[rdev2->desc_nr];
 		nr_disks++;
@@ -1722,7 +1728,7 @@ static void super_90_sync(struct mddev *mddev, struct md_rdev *rdev)
 			d->state |= (1<<MD_DISK_FAILFAST);
 	}
 	/* now set the "removed" and "faulty" bits on any missing devices */
-	for (i=0 ; i < mddev->raid_disks ; i++) {
+	for (i = 0; i < mddev->raid_disks && i < MD_SB_DISKS; i++) {
 		mdp_disk_t *d = &sb->disks[i];
 		if (d->state == 0 && d->number == 0) {
 			d->number = i;
--
2.55.0


  parent reply	other threads:[~2026-09-13 23:46 UTC|newest]

Thread overview: 8+ 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-13 23:37   ` [PATCH] md: add max_disks bound check in older version Aaditya Kansal
2026-09-13 23:37     ` syzbot
2026-09-13 23:51     ` sashiko-bot
2026-09-13 23:44   ` Aaditya Kansal [this message]
2026-09-13 23:46     ` syzbot
2026-09-14  0:02     ` sashiko-bot

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=20260913234627.465492-1-aadityakansal390@gmail.com \
    --to=aadityakansal390@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=syzbot+9e3014263a35700ab49b@syzkaller.appspotmail.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