提交 c19bd04b 编写于 作者: Y Yufen Yu 提交者: Joseph Qi

md: make sure desc_nr less than MD_SB_DISKS

commit 3b7436cc9449d5ff7fa1c1fd5bc3edb6402ff5b8 upstream.

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: NYufen Yu <yuyufen@huawei.com>
Signed-off-by: NSong Liu <songliubraving@fb.com>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
上级 38ce05b0
...@@ -1096,6 +1096,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor ...@@ -1096,6 +1096,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
/* not spare disk, or LEVEL_MULTIPATH */ /* not spare disk, or LEVEL_MULTIPATH */
if (sb->level == LEVEL_MULTIPATH || if (sb->level == LEVEL_MULTIPATH ||
(rdev->desc_nr >= 0 && (rdev->desc_nr >= 0 &&
rdev->desc_nr < MD_SB_DISKS &&
sb->disks[rdev->desc_nr].state & sb->disks[rdev->desc_nr].state &
((1<<MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE)))) ((1<<MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE))))
spare_disk = false; spare_disk = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册