Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3678048pxb; Mon, 24 Jan 2022 15:08:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxq+HVQNHk2hRCb/70e4lIYv6jKQg7hfpvJbiI379i2iD8l+51mEieyiTis0wtUJP3+rhET X-Received: by 2002:a05:6a00:1945:b0:4c3:39cc:52c6 with SMTP id s5-20020a056a00194500b004c339cc52c6mr15598656pfk.18.1643065681826; Mon, 24 Jan 2022 15:08:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065681; cv=none; d=google.com; s=arc-20160816; b=aAPHTQrhcTrq9bNgBwkkXc9auRBiUgr87cZ/qjLahHScYbKE6rMwh3DlU3azUQJasi 9knk2UzGXNAjupTW8hHsRNjdxbvqXff1+NmiVVf5azc9Uea6gluOIvM2lb1J7HGcKyge hQOGc40c6yaOpDS1NCikPP7Ai445CciOpwnlVzMevMXWA60gdrQ7plN75JwIeojYwbLu U4hsxJTqyVKUK92WzJ2Lb+9bfTbqynX6ZHjhpkO6k/BQS8eSvYL5OzBFc6lecQ47UDmp XGZcN7AVPublVZRLypOddvTCa0l5TNsIRAQyxKinkqf59blV9iCCNR5jU8tYEnLyyOc3 A6GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5mgDOmkPSu1byoIksPiRD5JqIanyDsKx3ackeLXFOyI=; b=e31qVGh+iX1V0b7ncGJrp5g0XqaLhSlJtUl4ZVprFIsYkKnDKJK8CmexG10gv8YiJw Nu9FkNUK09url/7YEQyvW4McA1Whs4CdweS38sIxKgQbPCPe+y+FWpdGH89C5veG4rqy V/7msK/CYIf1iqPrtmOUlvbML3cSTuOuXXDIewe6mDjoNfABm35q3ff3NITcIyfObjgH Sb1nSPdC326ed7gfDUL7P9IipuPtN1zXk2EVGo7QKrVGAa5Uelj2tFv3Go0aLAYXC9Gr B7XZOtkIHf99NFNhvxw/NA3FUBKyR1DwIxuxmfyB52YkW95qGpLrTKdT2ygNHBbE9CTR mhfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZQNb8Ktz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si5498253plh.450.2022.01.24.15.07.42; Mon, 24 Jan 2022 15:08:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZQNb8Ktz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1843126AbiAXXDX (ORCPT + 99 others); Mon, 24 Jan 2022 18:03:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1577768AbiAXWBE (ORCPT ); Mon, 24 Jan 2022 17:01:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78140C0C0939; Mon, 24 Jan 2022 12:40:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 356E4B80FA3; Mon, 24 Jan 2022 20:40:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 600F4C340E7; Mon, 24 Jan 2022 20:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056806; bh=+j/hF9KUbkWpVpF0TWD+CJhI+JZR0eec5rq0R+03JEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQNb8KtzpzDaOuVZeYkOziX0n47YcGA5TiTyxESXbFzXvqgnHmQ66tNvI8ogDS8nx g6nJhrgduBDPc9FcJ126OthgQtMZ+FoGUkya8tyMjSr9hvFIaUdOtETSnf0uouWXfJ uO+OWcXCXkhKM3S165QyQ+sCmzlnVUVJfu1GFSpA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joe Thornber , Mike Snitzer , Sasha Levin Subject: [PATCH 5.15 605/846] dm space map common: add bounds check to sm_ll_lookup_bitmap() Date: Mon, 24 Jan 2022 19:42:02 +0100 Message-Id: <20220124184121.892034238@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joe Thornber [ Upstream commit cba23ac158db7f3cd48a923d6861bee2eb7a2978 ] Corrupted metadata could warrant returning error from sm_ll_lookup_bitmap(). Signed-off-by: Joe Thornber Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin --- 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