mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Down <chris@chrisdown.name>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai@fygo.io>
Cc: Li Nan <magiclinan@didiglobal.com>, Xiao Ni <xiao@kernel.org>,
	linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com
Subject: [PATCH] md/raid10: Prevent data corruption after a rejected backwards reshape
Date: Sun, 8 Nov 2026 00:47:33 -0800	[thread overview]
Message-ID: <avA3JQ6lyAlMm1Q8@chrisdown.name> (raw)

A rejected backwards RAID10 reshape can leave the array using the
requested geometry because raid10_start_reshape() updates conf->geo
before checking whether the new geometry can hold the current array
size. If the check fails, we return -EINVAL with the new geometry still
in place. Subsequent I/O then uses a layout the data hasn't been moved
to, so reads can return the wrong data and writes can silently corrupt
the array.

To fix this, let's take the existing abort path to restore the old
geometry.

Fixes: 3ea7daa5d7fd ("md/raid10: add reshape support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Chris Down <chris@chrisdown.name>
---
 drivers/md/raid10.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 066c43154497..4ade0cf3281f 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4393,7 +4393,8 @@ static int raid10_start_reshape(struct mddev *mddev)
 			spin_unlock_irq(&conf->device_lock);
 			pr_warn("md/raid10:%s: array size must be reduce before number of disks\n",
 				mdname(mddev));
-			return -EINVAL;
+			ret = -EINVAL;
+			goto abort;
 		}
 		mddev->resync_max_sectors = size;
 		conf->reshape_progress = size;

base-commit: 47e1b18f38d74015cb9fd30b5ff2a1eb88e77d31

                 reply	other threads:[~2026-11-08  8:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=avA3JQ6lyAlMm1Q8@chrisdown.name \
    --to=chris@chrisdown.name \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=magiclinan@didiglobal.com \
    --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

all inboxes | Powered by JetHome®