Skip to content

Commit 3b7436c

Browse files
Yufen Yuliu-song-6
authored andcommitted
md: make sure desc_nr less than MD_SB_DISKS
For super_90_load, we need to make sure 'desc_nr' less than MD_SB_DISKS, avoiding invalid memory access of 'sb->disks'. Fixes: 228fc7d ("md: avoid invalid memory access for array sb->dev_roles") Signed-off-by: Yufen Yu <yuyufen@huawei.com> Signed-off-by: Song Liu <songliubraving@fb.com>
1 parent 028288d commit 3b7436c

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎drivers/md/md.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
11591159
/* not spare disk, or LEVEL_MULTIPATH */
11601160
if (sb->level == LEVEL_MULTIPATH ||
11611161
(rdev->desc_nr >= 0 &&
1162+
rdev->desc_nr < MD_SB_DISKS &&
11621163
sb->disks[rdev->desc_nr].state &
11631164
((1<<MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE))))
11641165
spare_disk = false;

0 commit comments

Comments
 (0)