提交 643b11a3 编写于 作者: J Joe Thornber 提交者: Yongqiang Liu

dm space map common: add bounds check to sm_ll_lookup_bitmap()

stable inclusion
from linux-4.19.226
commit 7d585b602a5c054e810b8f47183069872ac2fdf6

--------------------------------

[ Upstream commit cba23ac1 ]

Corrupted metadata could warrant returning error from sm_ll_lookup_bitmap().
Signed-off-by: NJoe Thornber <ejt@redhat.com>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
Signed-off-by: NLaibin Qiu <qiulaibin@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 b1ba67ab
...@@ -279,6 +279,11 @@ int sm_ll_lookup_bitmap(struct ll_disk *ll, dm_block_t b, uint32_t *result) ...@@ -279,6 +279,11 @@ int sm_ll_lookup_bitmap(struct ll_disk *ll, dm_block_t b, uint32_t *result)
struct disk_index_entry ie_disk; struct disk_index_entry ie_disk;
struct dm_block *blk; struct dm_block *blk;
if (b >= ll->nr_blocks) {
DMERR_LIMIT("metadata block out of bounds");
return -EINVAL;
}
b = do_div(index, ll->entries_per_block); b = do_div(index, ll->entries_per_block);
r = ll->load_ie(ll, index, &ie_disk); r = ll->load_ie(ll, index, &ie_disk);
if (r < 0) if (r < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册