[PATCH] md/raid10: Prevent data corruption after a rejected backwards reshape

From: Chris Down

Date: Sun Nov 08 2026 - 03:47:59 EST


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@xxxxxxxxxxxxxxx>
Signed-off-by: Chris Down <chris@xxxxxxxxxxxxxx>
---
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