The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: syzbot <syzbot+de94ddbfff0c9e6fe030@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Forwarded: [PATCH] md: enforce minimum of 2 disks for raid 4 and 5
Date: Sat, 08 Aug 2026 19:27:23 -0700	[thread overview]
Message-ID: <6a77e58b.01d0871a.3a0d52.007d.GAE@google.com> (raw)
In-Reply-To: <6a778c82.01d0871a.3a0d52.006a.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: [PATCH] md: enforce minimum of 2 disks for raid 4 and 5
Author: ryan.mehri1@gmail.com

#syz test

Signed-off-by: Ryan Mehri <ryan.mehri1@gmail.com>
---
 drivers/md/raid5.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ffb5fcde54a9..e02c579d4ceb 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -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);
-- 
2.55.0


      reply	other threads:[~2026-08-09  2:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08 20:07 [syzbot] [raid?] UBSAN: shift-out-of-bounds in raid5_set_limits syzbot
2026-08-09  2:27 ` syzbot [this message]

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=6a77e58b.01d0871a.3a0d52.007d.GAE@google.com \
    --to=syzbot+de94ddbfff0c9e6fe030@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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