Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Junrui Luo and committed by
Yu Kuai
9aa6d860 f7b24c7b

+2
+2
drivers/md/raid10.c
··· 3791 3791 nc = layout & 255; 3792 3792 fc = (layout >> 8) & 255; 3793 3793 fo = layout & (1<<16); 3794 + if (!nc || !fc) 3795 + return -1; 3794 3796 geo->raid_disks = disks; 3795 3797 geo->near_copies = nc; 3796 3798 geo->far_copies = fc;