From: sashiko-bot@kernel.org
To: "Shuai Liu" <847807867@qq.com>, linux-raid@vger.kernel.org
Cc: yukuai@fygo.io
Subject: Re: [PATCH] md: reject out-of-bounds desc_nr in super_90_validate()
Date: Mon, 16 Nov 2026 08:54:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-216570@kernel.org> (raw)
In-Reply-To: <tencent_3583131EEE6BD2102C15F21A4DEEB86A6208@qq.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] md: ignored super_90_validate() error in md_add_new_disk()
and add_bound_rdev()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Medium] md: missing raid_disk and delta_disks validation in
super_90_validate() [1]
--
commit 8c2da3468482d3b2e5d7496a1240f196823bd4e4
Author: Shuai Liu <847807867@qq.com>
md: reject out-of-bounds desc_nr in super_90_validate()
This commit adds a bounds check on rdev->desc_nr in super_90_validate() to
reject values outside [0, MD_SB_DISKS) with -EINVAL before indexing
sb->disks[].
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 03e35386a8028..83009b0d84092 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -1495,6 +1495,9 @@ static int super_90_validate(struct mddev *mddev, struct md_rdev *freshest, stru
> mdp_super_t *sb = page_address(rdev->sb_page);
> __u64 ev1 = md_event(sb);
>
> + if (rdev->desc_nr < 0 || rdev->desc_nr >= MD_SB_DISKS)
> + return -EINVAL;
> +
> rdev->raid_disk = -1;
> clear_bit(Faulty, &rdev->flags);
> clear_bit(In_sync, &rdev->flags);
[Severity: Medium]
Can a hot-added disk with an out-of-bounds sb->this_disk.number still be
accepted onto a running persistent v0.90 array?
Both md_add_new_disk() and add_bound_rdev() ignore the return value of
validate_super(), and unlike super_1_validate(), super_90_validate() does
not reset rdev->desc_nr = -1 on failure. When sb->this_disk.number >=
MD_SB_DISKS and MD_DISK_JOURNAL is set, bind_rdev_to_array() skips its
max_disks check and add_bound_rdev() proceeds to hot_add_disk() with the
out-of-bounds rdev->desc_nr intact. When sb->this_disk.number < 0,
bind_rdev_to_array() reassigns rdev->desc_nr to an in-range slot and the
second validate_super() call in add_bound_rdev() reads a different
descriptor slot than sb->this_disk.number.
[Severity: Medium]
This problem wasn't introduced by this patch, but can unvalidated
sb->delta_disks and desc->raid_disk values in super_90_validate() cause
out-of-bounds indexing into personality disk arrays [1]?
super_90_validate() copies sb->delta_disks into mddev->delta_disks and
desc->raid_disk into rdev->raid_disk without bounds checks:
drivers/md/md.c:super_90_validate() {
...
if (mddev->minor_version >= 91) {
mddev->reshape_position = sb->reshape_position;
mddev->delta_disks = sb->delta_disks;
...
} else if (desc->state & (1<<MD_DISK_SYNC)) {
set_bit(In_sync, &rdev->flags);
rdev->raid_disk = desc->raid_disk;
rdev->saved_raid_disk = desc->raid_disk;
...
}
When hot-adding via add_bound_rdev(), mddev->pers->hot_add_disk() is
called directly after super_90_validate() without analyze_sbs(). Even
during assembly, a desc->raid_disk >= 0x80000000 becomes a negative
rdev->raid_disk (< -1) with In_sync set, or a negative sb->delta_disks
inflates the upper bound in analyze_sbs() past mddev->raid_disks.
Personality handlers such as raid1_add_disk() then index
conf->mirrors[rdev->raid_disk] out of bounds.
[1] https://sashiko.dev/#/bug/linux-9ad89505-1b9e-435b-941d-6a126f8f4adb
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_3583131EEE6BD2102C15F21A4DEEB86A6208@qq.com?part=1
next prev parent reply other threads:[~2026-11-16 8:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 22:06 [syzbot] [raid?] KASAN: slab-out-of-bounds Read in super_90_validate syzbot
2026-11-16 8:32 ` [PATCH] md: reject out-of-bounds desc_nr in super_90_validate() Shuai Liu
2026-11-16 8:54 ` sashiko-bot [this message]
2026-11-16 8:59 ` [PATCH v2] " Shuai Liu
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=sashiko-outbox-216570@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=847807867@qq.com \
--cc=linux-raid@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yukuai@fygo.io \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.