md/raid10: Prevent data corruption after a rejected backwards reshape
PATCH 1/1 md/raid10: Prevent data corruption after a rejected backwards reshape
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.
--- drivers/md/raid10.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid10.c +2 -1
@@ -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
Quoted 11 lines · Chris Down
A rejected backwards RAID10 reshape can leave the array using the requested geometry because
raid10_start_reshape()updatesconf->geobefore checking whether the new geometry can hold the current array size. If the check fails, we return-EINVALwith 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.
Quoted 6 lines
Fixes 3ea7daa5d7fd ("md/raid10: add reshape support")Cc <[email protected]>Signed-off-by Chris Down<[email protected]>--- drivers/md/raid10.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied
Signature · 2 lines
Thanks, Kuai