diff options
author | Joe Thornber <ejt@redhat.com> | 2021-12-10 16:49:53 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-01-27 11:19:46 +0300 |
commit | b3fbe7565f8e2d10178e8b99578f7a3a13a6d142 (patch) | |
tree | c23eb43089d9b6a1a200a8f9113ef65b08c177bd /drivers/md | |
parent | 052f6401370104f3a058b11ca12b65e9df47c17e (diff) | |
download | linux-b3fbe7565f8e2d10178e8b99578f7a3a13a6d142.tar.xz |
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: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/persistent-data/dm-space-map-common.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/md/persistent-data/dm-space-map-common.c b/drivers/md/persistent-data/dm-space-map-common.c index a213bf11738f..85853ab62971 100644 --- a/drivers/md/persistent-data/dm-space-map-common.c +++ b/drivers/md/persistent-data/dm-space-map-common.c @@ -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) |