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

Corrupted metadata could warrant returning error from sm_ll_lookup_bitmap().

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
This commit is contained in:
Joe Thornber 2021-12-10 13:49:53 +00:00 committed by Mike Snitzer
parent 85bca3c05b
commit cba23ac158

View File

@ -283,6 +283,11 @@ int sm_ll_lookup_bitmap(struct ll_disk *ll, dm_block_t b, uint32_t *result)
struct disk_index_entry ie_disk;
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);
r = ll->load_ie(ll, index, &ie_disk);
if (r < 0)