Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3558119pxb; Mon, 24 Jan 2022 12:10:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHjx5PCYS4of+2K608vbwDDgIp6px1mI+5mIV0A1L0vLAM7/IvSx7ntqId28PorWqr3eYK X-Received: by 2002:a05:6a00:15c3:b0:4c8:fc0f:4489 with SMTP id o3-20020a056a0015c300b004c8fc0f4489mr6818828pfu.9.1643055057104; Mon, 24 Jan 2022 12:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055057; cv=none; d=google.com; s=arc-20160816; b=K+MO3JTFPKsTyVZPr9n5hOOJbPOQb7wQg9qlOyP+FJeZCKVWRCdxl6POcCsv1OJ3bJ 6GfZ2DhDxBvjoLFxB0zWY8QXfSuySjoPMn4WXcZ2hdMiYQ4JGjSnOlDZ1ttlK7uSpCs4 OLeFLpyCeDWz2+Z3RB12orjpZpgqTVkaNkcmrXkdp58TFJe/RAbgEaJdKjNYAM8PY6tT 1Q6Ct9/2Xm18o8xTlUdfw4NXLkBe/GKT6bz3GSdUSK0ddob1huOTY7KOiW0x9FmaqF8B 3Py5kWOWG1ROZg1TpNlE80a4uuI1OKa3OV29/ln8JMUg/+AsDXi/+lIk4j83mGXjLnnk 7f0g== 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=8tsHj2o2eOQaLQk/Q3aMQb08ocGGouk4kbYgzQ1Z5JU=; b=I+L7OaxngbPEeX3yN9W0gEHRZ/omcnl03CrxE2I+6UuTSEJ8YYSnlH6I7J+cTEfYrM pMXMSxPThgxjbvqUrg6ZZ5NfXfg6lNwoEU79uosbAPphlE4IpUI5m5bu58VvvH18SniC PlcehdaAXxalJJENB9Ji7wPFb/X0cLx5kRrsq/VgEzt9M+/l61XCWuHXqJOQPiB4Z1lC q17rcs9nWL7L5Z3SS2IEkUnyvPV+wylWbUXu86OHspWg5y2fr5ORWIL//oU3L0hRIKtm QjOQeft/AvN7Uvxs4OC1zITTfDnHI2qB0AVEot2HACjbb1Mv9ygGIGcrXv/KJ8xYfmRW U1vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="KD91//CE"; 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 x191si9568204pgd.354.2022.01.24.12.10.44; Mon, 24 Jan 2022 12:10:57 -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="KD91//CE"; 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 S1347081AbiAXTJl (ORCPT + 99 others); Mon, 24 Jan 2022 14:09:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345290AbiAXTDN (ORCPT ); Mon, 24 Jan 2022 14:03:13 -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 80EC5C06175B; Mon, 24 Jan 2022 10:59:15 -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 47693B81227; Mon, 24 Jan 2022 18:59:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65046C340E7; Mon, 24 Jan 2022 18:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050753; bh=PE5eRi3IE9VNLlQ1ed9CSr4cABoF8ehAGM5W/x8b8/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KD91//CEVsu1WGngMaEKLrmK5aJ016cj0/OzMaCq/E69dNbzgL4crpsSy/RaXIJv4 UBft3QxkVOX2jshKJV4A8tqZyurGjWc7cFsC9whhgTQ/ffq0sZQ0/RXjhMMmATWM7l /0wfx/cf9HdmTyjv/4Sq9cQC+w2KTWx+jivV5ayU= 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 4.9 101/157] dm space map common: add bounds check to sm_ll_lookup_bitmap() Date: Mon, 24 Jan 2022 19:43:11 +0100 Message-Id: <20220124183935.966414011@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183932.787526760@linuxfoundation.org> References: <20220124183932.787526760@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 ca09ad2a639c4..6fa4a68e78b0d 100644 --- a/drivers/md/persistent-data/dm-space-map-common.c +++ b/drivers/md/persistent-data/dm-space-map-common.c @@ -279,6 +279,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