mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-08-18 12:11:02 +00:00
md/raid10: fix divide-by-zero in setup_geo() with zero far_copies
commit 9aa6d860b0930e2f72795665c42c44252a558a0c upstream.
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: 475901aff1 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
@ -3662,6 +3662,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;
|
||||
|
||||
Reference in New Issue
Block a user