Skip to content

Commit

Permalink
dm space map common: add bounds check to sm_ll_lookup_bitmap()
Browse files Browse the repository at this point in the history
[ Upstream commit cba23ac ]

Corrupted metadata could warrant returning error from sm_ll_lookup_bitmap().

Signed-off-by: Joe Thornber <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
jthornber authored and gregkh committed Jan 27, 2022
1 parent b5aee20 commit 1674124
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/md/persistent-data/dm-space-map-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1674124

Please sign in to comment.