Skip to content

Commit 8b0472b

Browse files
ZhangShurongliu-song-6
authored andcommitted
md: raid1: fix potential OOB in raid1_remove_disk()
If rddev->raid_disk is greater than mddev->raid_disks, there will be an out-of-bounds in raid1_remove_disk(). We have already found similar reports as follows: 1) commit d17f744 ("md-raid10: fix KASAN warning") 2) commit 1ebc2ce ("dm raid: fix KASAN warning in raid5_remove_disk") Fix this bug by checking whether the "number" variable is valid. Signed-off-by: Zhang Shurong <[email protected]> Reviewed-by: Yu Kuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]>
1 parent a705b11 commit 8b0472b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/md/raid1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,10 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
18371837
struct r1conf *conf = mddev->private;
18381838
int err = 0;
18391839
int number = rdev->raid_disk;
1840+
1841+
if (unlikely(number >= conf->raid_disks))
1842+
goto abort;
1843+
18401844
struct raid1_info *p = conf->mirrors + number;
18411845

18421846
if (rdev != p->rdev)

0 commit comments

Comments
 (0)