From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796323969; b=K56LVFivztrjIRrqKDL7XpQZImPWXwwUb1gwxy0GE5s419fP9lu+4c9gFLQiIn9PXuWo nVC2atsY8ZN5PuX/HD0jCOZaU11HuMEJ2ncWRDgNwEXJuqZadsNGUQhhSHdWUXsjCYneS nYrR5/HyTU8bwRI4bNpKbWGUHn+1wO9Z6dnuLWgxVIjtKzdJm14m4d0NysEghUuLRNNq6 CEB623V9Cl/qyHPOvicUNB9D0AygrVrALIqrxouYkw/X1fDxZkHpo4HQdNxEong1B3KI+ x2BUe1LPJk/8P23tmR99u/oHIP3tIdpdzZhW+LhJICIPTn6Y4JraZT7HokzSxpB6b2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796323969; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=xa46IlXBSxyOKe2mF2EmoKjEHXfJVooDtJWBckbYmHY=; b=kyhXFHVXhcwdFbTspd6X1/UIZ3o7nE1WzWKBeVAxAhX5fc45muotb8LLZt5uN7pXU23t /h8n3LUE3QUOrPSz7sL+0nXznoxhe6G5a9h7AsHySWmnMoSv7dEDG+g+VaEMJG3ng2wxV 48H0dY5uz9f8iYYiLZPY3naUlRREf89ML+ooWQLE4C/zPJokLOyrQqKOqzzNP2EogFqrh CyFnpyZX5y3pVYqF392vgWfmELUYGiwX9hMYrl+GX/wwp/JSRHvBD7N0OQw1UeytYfD40 DthOMhzonJqJTZxB8g/2t/LHtn1dXKX+H620mYCWWjFAqB3Fa/uficf1SrSaf2PtKrQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ClnzEJzW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8D77606A32D for ; Thu, 3 Dec 2026 18:52:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ClnzEJzW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9965E1F000C1; Thu, 3 Dec 2026 18:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796323969; bh=xa46IlXBSxyOKe2mF2EmoKjEHXfJVooDtJWBckbYmHY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ClnzEJzWJPh2jST4NdkDIElrsCWxYKlZlQZckFfN1pdG3W9W5JBiLKEslgjwlJsZw FUDWTjI+En2cIy9OWbCZznSM5xKwzcjX/+oGIhotIOx+RrAwJvdKs+c0b1WHlwSSZA hU7s8JJPtaU5HalF40mvC/Dk8DPdMwVGaL0coxKxJbSQFcAs4r7BLM9EOAQCiPILqP bmikcBaQVYuTJ63iT3QqXTbRUkzXvGUTpEVUmyXk8uEeSSRTGlEUeDxyiDANoPv3kE 1xwqvyb3Kzm3OpUFliO8llsEnAirMAysdzISGr2XU9cWU5H8W1+NHM8oJF12ZYYWEJ AbpDByBVzWkPA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] md: reject inconsistent reshape state during assembly Reply-To: sashiko-reviews@lists.linux.dev To: "Kyuwon Cho" Cc: linux-raid@vger.kernel.org, yukuai@fygo.io In-Reply-To: <179631974158.3729010.8619704387637000613@gmail.com> References: <179631974158.3729010.8619704387637000613@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 18:52:49 +0000 X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] md: analyze_sbs() rejects valid RAID0 arrays after layout is set to -1 - [High] md: analyze_sbs() leaves mddev dirty on error, letting retry bypass check - [Low] md: Fixes trailer cites ba1b41b6b4e3 instead of f67055780caa -- commit 1147b5c6a5554cf79c98716d0222c0847e7320b2 Author: Kyuwon Cho > md: reject inconsistent reshape state during assembly > > 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.540355729= 8223708081@gmail.com/ > Signed-off-by: Kyuwon Cho [Severity: Low] Should the Fixes tag cite commit f67055780caa ("[PATCH] md: Checkpoint and allow restart of raid5 reshape") instead? Commit ba1b41b6b4e3 ("md: range check slot number when manually adding a spare.") only added an upper bound check in slot_store(), whereas the unvalidated copying of reshape fields in super_90_validate() and super_1_validate() was introduced by the earlier commit. > diff --git a/drivers/md/md.c b/drivers/md/md.c > index 47da9edc1c606..b4ba5c8f1bf6d 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -3948,6 +3948,14 @@ static int analyze_sbs(struct mddev *mddev) > =20 > super_types[mddev->major_version]. > validate_super(mddev, NULL/*freshest*/, freshest); > + if (mddev->reshape_position =3D=3D MaxSector && > + (mddev->level !=3D mddev->new_level || > + mddev->layout !=3D mddev->new_layout || > + mddev->chunk_sectors !=3D mddev->new_chunk_sectors || > + mddev->delta_disks !=3D 0)) { [Severity: High] Does this regression reject valid RAID0 arrays during assembly? In super_90_validate(), the non-reshape branch copies mddev->layout into mddev->new_layout and then overrides mddev->layout to -1 without updating mddev->new_layout: drivers/md/md.c:super_90_validate() { ... mddev->new_layout =3D mddev->layout; mddev->new_chunk_sectors =3D mddev->chunk_sectors; } if (mddev->level =3D=3D 0) mddev->layout =3D -1; ... } super_1_validate() does the same when MD_FEATURE_RAID0_LAYOUT is not set. For a normal RAID0 superblock with layout 0, mddev->layout (-1) then differs from mddev->new_layout (0), causing analyze_sbs() to fail with -EINVAL. > + pr_warn("md: %s: inconsistent reshape state\n", mdname(mddev)); > + return -EINVAL; > + } [Severity: High] Can a second RUN_ARRAY ioctl bypass this check because validate_super() already populated mddev->raid_disks? Returning -EINVAL here leaves mddev->raid_disks and mddev->delta_disks set to the values loaded from the superblock, and neither md_run() nor do_md_run() resets mddev on error. On a retry, md_run() sees mddev->raid_disks !=3D 0 and skips analyze_sbs(), starting the array with the rejected delta_disks. slot_store() can then still trigger the slab-out-of-bounds access in raid10_add_disk(). Resetting mddev on this error path, or validating the superblock before mutating mddev, would prevent the retry bypass. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179631974158.372901= 0.8619704387637000613@gmail.com?part=3D1