summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYufen Yu <yuyufen@huawei.com>2019-12-10 08:01:29 +0100
committerSong Liu <songliubraving@fb.com>2019-12-11 19:38:08 +0100
commit3b7436cc9449d5ff7fa1c1fd5bc3edb6402ff5b8 (patch)
tree1c03c1bb7e5d3fed74e2655e572ec6dd00809563
parentmd: raid1: check rdev before reference in raid1_sync_request func (diff)
downloadlinux-3b7436cc9449d5ff7fa1c1fd5bc3edb6402ff5b8.tar.xz
linux-3b7436cc9449d5ff7fa1c1fd5bc3edb6402ff5b8.zip
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: 228fc7d76db6 ("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>
-rw-r--r--drivers/md/md.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 805b33e27496..4e7c9f398bc6 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1159,6 +1159,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
/* not spare disk, or LEVEL_MULTIPATH */
if (sb->level == LEVEL_MULTIPATH ||
(rdev->desc_nr >= 0 &&
+ rdev->desc_nr < MD_SB_DISKS &&
sb->disks[rdev->desc_nr].state &
((1<<MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE))))
spare_disk = false;