Linux RAID subsystem development
 help / color / mirror / Atom feed
From: "yu kuai" <yukuai@fygo.io>
To: <sashiko-reviews@lists.linux.dev>,
	"Chen Cheng" <chencheng@fnnas.com>,  "yu kuai" <yukuai@fygo.io>
Cc: <linux-raid@vger.kernel.org>
Subject: Re: [PATCH v3] md/raid5: reject raid4/5 arrays with too few disks
Date: Sat, 12 Sep 2026 19:45:21 +0800	[thread overview]
Message-ID: <0bbda44a-3d5f-43b0-a1f5-51ee57469902@fygo.io> (raw)
In-Reply-To: <20260911042717.487AC1F00898@smtp.kernel.org>

Hi,

在 2026/9/11 12:27, sashiko-bot@kernel.org 写道:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] Division by zero in `raid5_run()` when assembling an array with an active reshape and insufficient data disks.
> --
>
> commit e2bb0701d8414cbf17eed6287965f8022ffe5eab
> Author: Chen Cheng <chencheng@fnnas.com>
>
> md/raid5: reject raid4/5 arrays with too few disks
>
> raid4 and raid5 require at least two disks, while raid6 requires at least
> four disks. setup_conf() only rejects raid6 arrays with fewer than four
> disks. As a result, an invalid raid4 or raid5 array can be assembled with
> no data disks and later reach raid5_set_limits().
>
> Reported-by: syzbot+de94ddbfff0c9e6fe030@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/r/6a778c82.01d0871a.3a0d52.006a.GAE@google.com/
> Fixes: f63f17350e53 ("md/raid5: use the atomic queue limit update APIs")
>
>> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
>> index b91545ce090de..e1f20035703ba 100644
>> --- a/drivers/md/raid5.c
>> +++ b/drivers/md/raid5.c
>> @@ -7657,9 +7657,11 @@ static struct r5conf *setup_conf(struct mddev *mddev)
>>   			mdname(mddev), mddev->new_layout);
>>   		return ERR_PTR(-EIO);
>>   	}
>> -	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);
>> +	if ((mddev->new_level != 6 && mddev->raid_disks < 2) ||
>> +	    (mddev->new_level == 6 && mddev->raid_disks < 4)) {
>> +		pr_warn("md/raid:%s: not enough configured devices (%d, minimum %d)\n",
>> +			mdname(mddev), mddev->raid_disks,
>> +			mddev->new_level == 6 ? 4 : 2);
> [Severity: High]
> This isn't a bug introduced by this patch, but does this fully prevent
> invalid array geometries from causing panics during array assembly?
>
> In raid5_run(), if there is an active reshape and the array is assembled with
> insufficient data disks, we calculate new_data_disks and divide by it before
> setup_conf() is called to validate the array geometry:
>
> drivers/md/raid5.c:raid5_run() {
>      if (mddev->reshape_position != MaxSector) {
>          ...
>          new_data_disks = mddev->raid_disks - max_degraded;
>          if (sector_div(here_new, chunk_sectors * new_data_disks)) {
>              ...
>          }
>          ...
>          sector_div(here_old, chunk_sectors * (old_disks-max_degraded));
>      }
>      ...
>      if (mddev->private == NULL)
>          conf = setup_conf(mddev);
> }
This looks like a valid problem as well.
>
> If a crafted superblock sets raid_disks <= max_degraded and reshape_position
> is not MaxSector, these divisions by zero are reached before the new checks
> in setup_conf() can reject the array.
>
> Could these checks be moved earlier in the assembly path to prevent the
> divide-by-zero panics?
>
>>   		return ERR_PTR(-EINVAL);
>>   	}
>>
-- 
Thanks,
Kuai

  reply	other threads:[~2026-09-12 11:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  4:15 [PATCH v3] md/raid5: reject raid4/5 arrays with too few disks Chen Cheng
2026-09-11  4:27 ` sashiko-bot
2026-09-12 11:45   ` yu kuai [this message]
2026-09-12 11:46 ` yu kuai

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=0bbda44a-3d5f-43b0-a1f5-51ee57469902@fygo.io \
    --to=yukuai@fygo.io \
    --cc=chencheng@fnnas.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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