aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2021-12-10 13:49:53 +0000
committerMike Snitzer <snitzer@redhat.com>2022-01-04 13:58:19 -0500
commitcba23ac158db7f3cd48a923d6861bee2eb7a2978 (patch)
treee485c359c570b4d51c7dc458f218f8dfdf4dfb53
parentdm btree: add a defensive bounds check to insert_at() (diff)
downloadlinux-dev-cba23ac158db7f3cd48a923d6861bee2eb7a2978.tar.xz
linux-dev-cba23ac158db7f3cd48a923d6861bee2eb7a2978.zip
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>
-rw-r--r--drivers/md/persistent-data/dm-space-map-common.c5
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 4a6a2a9b4eb4..bfbfa750e016 100644
--- a/drivers/md/persistent-data/dm-space-map-common.c
+++ b/drivers/md/persistent-data/dm-space-map-common.c
@@ -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)