From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai@fygo.io>
Cc: Li Nan <magiclinan@didiglobal.com>, Xiao Ni <xiao@kernel.org>,
NeilBrown <neil@brown.name>,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] md: reject inconsistent reshape state during assembly
Date: Fri, 4 Dec 2026 03:26:25 +0900 [thread overview]
Message-ID: <179631974158.3729010.8619704387637000613@gmail.com> (raw)
slot_store() permits a slot below raid_disks + delta_disks while a
reshape prepares additional slots. The v0.90 and v1.x validators can
copy a nonzero delta_disks from a superblock whose reshape_position is
MaxSector. The stale delta lets slot_store() pass an out-of-range slot
to a personality whose table was allocated for raid_disks only.
KASAN reports:
BUG: KASAN: slab-out-of-bounds in raid10_add_disk (drivers/md/raid10.c:2106)
Call Trace:
raid10_add_disk (drivers/md/raid10.c:2106)
slot_store (drivers/md/md.c:3370)
rdev_attr_store (drivers/md/md.c:3788)
Reject the array in analyze_sbs() when no reshape is in progress but
any reshape geometry differs. This catches both metadata formats in
their common assembly path, before a personality allocates its runtime
geometry.
Fixes: ba1b41b6b4e3 ("md: range check slot number when manually adding a spare.")
Closes: https://lore.kernel.org/linux-raid/179489219553.3099317.5403557298223708081@gmail.com/
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
The bug was found with an LLM-guided test generator. The original report is at https://lore.kernel.org/linux-raid/179489219553.3099317.5403557298223708081@gmail.com/. A reproducer is available on request.
---
drivers/md/md.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c71c3b043496..1cf2cfdd8643 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3943,6 +3943,14 @@ static int analyze_sbs(struct mddev *mddev)
super_types[mddev->major_version].
validate_super(mddev, NULL/*freshest*/, freshest);
+ if (mddev->reshape_position == MaxSector &&
+ (mddev->level != mddev->new_level ||
+ mddev->layout != mddev->new_layout ||
+ mddev->chunk_sectors != mddev->new_chunk_sectors ||
+ mddev->delta_disks != 0)) {
+ pr_warn("md: %s: inconsistent reshape state\n", mdname(mddev));
+ return -EINVAL;
+ }
rdev_for_each_safe(rdev, tmp, mddev) {
if (mddev->max_disks &&
next reply other threads:[~2026-12-03 18:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 18:26 Kyuwon Cho [this message]
2026-12-03 18:52 ` [PATCH] md: reject inconsistent reshape state during assembly 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=179631974158.3729010.8619704387637000613@gmail.com \
--to=kyuwoncho18@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=neil@brown.name \
--cc=song@kernel.org \
--cc=xiao@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox