Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3fbe756 authored by Joe Thornber's avatar Joe Thornber Committed by Greg Kroah-Hartman
Browse files

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



[ Upstream commit cba23ac158db7f3cd48a923d6861bee2eb7a2978 ]

Corrupted metadata could warrant returning error from sm_ll_lookup_bitmap().

Signed-off-by: default avatarJoe Thornber <ejt@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 052f6401
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -281,6 +281,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)