diff options
| author | Junrui Luo <moonafterrain@outlook.com> | 2026-04-16 06:39:56 +0300 |
|---|---|---|
| committer | Yu Kuai <yukuai@fnnas.com> | 2026-04-28 15:44:37 +0300 |
| commit | 9aa6d860b0930e2f72795665c42c44252a558a0c (patch) | |
| tree | 7552873fd79961f212561eaed7979d527a2134d5 | |
| parent | f7b24c7b41f23b5f9caa8b913afe79cd4c397d39 (diff) | |
| download | linux-9aa6d860b0930e2f72795665c42c44252a558a0c.tar.xz | |
md/raid10: fix divide-by-zero in setup_geo() with zero far_copies
setup_geo() extracts near_copies (nc) and far_copies (fc) from the
user-provided layout parameter without checking for zero. When fc=0
with the "improved" far set layout selected, 'geo->far_set_size =
disks / fc' triggers a divide-by-zero.
Validate nc and fc immediately after extraction, returning -1 if
either is zero.
Fixes: 475901aff158 ("MD RAID10: Improve redundancy for 'far' and 'offset' algorithms (part 1)")
Cc: stable@vger.kernel.org
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
Link: https://lore.kernel.org/linux-raid/SYBPR01MB7881A5E2556806CC1D318582AF232@SYBPR01MB7881.ausprd01.prod.outlook.com
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
| -rw-r--r-- | drivers/md/raid10.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 4901ebe45c87..39085e7dd6d2 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3791,6 +3791,8 @@ static int setup_geo(struct geom *geo, struct mddev *mddev, enum geo_type new) nc = layout & 255; fc = (layout >> 8) & 255; fo = layout & (1<<16); + if (!nc || !fc) + return -1; geo->raid_disks = disks; geo->near_copies = nc; geo->far_copies = fc; |
