lkml.org 
[lkml]   [2022]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 605/846] dm space map common: add bounds check to sm_ll_lookup_bitmap()
    Date
    From: Joe Thornber <ejt@redhat.com>

    [ 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>
    ---
    drivers/md/persistent-data/dm-space-map-common.c | 5 +++++
    1 file changed, 5 insertions(+)

    diff --git a/drivers/md/persistent-data/dm-space-map-common.c b/drivers/md/persistent-data/dm-space-map-common.c
    index 4a6a2a9b4eb49..bfbfa750e0160 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)
    --
    2.34.1


    \
     
     \ /
      Last update: 2022-01-25 01:11    [W:3.078 / U:0.100 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site