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

syzbot <[email protected]>
Newsgroups gmane.linux.kernel
Message-ID <[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

Signed-off-by: Ryan Mehri <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.