Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3973736pxb; Tue, 25 Jan 2022 00:22:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqfmmbSwZ4b6pW9qmXjbxpEEKa8DLuuVI6r6kegr66v55+xuqzOjCmCQMeESM3cfnM3MOp X-Received: by 2002:a17:906:5414:: with SMTP id q20mr15378766ejo.731.1643098925457; Tue, 25 Jan 2022 00:22:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098925; cv=none; d=google.com; s=arc-20160816; b=b7VbKbN/6KZ7mR/mPoeQSLQAjNEkhFJOXMeLLpQWLDfCksH7FFMqguzWMc2G9hILgA cQRGWref+Bqupd4iDM1IRFG6KCpsHBFz4EU1ZgJibQaqSCs0ytDtjG3pJUKYZxo2ONRc ZUHSsepfNzgTKISXoUcnpZOgcsRbbDVW69fkPziudRQhzbWFUxH8o+G/qNINC6Z9vQa9 ajEEPSIlOmkax6MU6P2J60ZKPdTy6P0aTwUfJckcBv4mYlfKOHOtm7+2uDoOSSGKINZ5 IoODjXPJP83lgHVX36dPbahWod2vIwA+iL+/3RHrsZMS4xTD9CSNZZNMZheDqXJeMGx5 uZfA== 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=pX8HWKj+jIbMjNLMy2RA44dUKwwc3rU0LnV2GvxcDwc=; b=tGSV2EQibeF3tpKCUcmx/Qi70FDh8TpgFj99F2aO9XZa/rLOumSMFwHSG5hafysOXz a3VMq08iTMULwNlfnEHQz4jVONUc1tkHd6xlk12Mlh9Rg5UG/iDUIw31BcdXSw/VizDC 3oTXoQuyq3TyTmdtATO7WKX6DU+4TF2ASq2TKt2TyTmSTbYOd23B40N1gjssHEnYlPws t1le9/PxGKdjBphErJoSEh7VltFeHtzFvGneuCiSjgFR2txPb8vcSVdqv/dxlyDum+15 HqWQQS7oYZcmUiQY8sUbcYmYpg53Uea0fIZG8V8IprqmCmpO3bc3zL4r8PmBmlN4zwwL DNKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1HI3Iz7E; 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 b10si9378524edx.107.2022.01.25.00.21.41; Tue, 25 Jan 2022 00:22:05 -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=1HI3Iz7E; 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 S3420679AbiAYCZF (ORCPT + 99 others); Mon, 24 Jan 2022 21:25:05 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:49106 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349496AbiAXTUx (ORCPT ); Mon, 24 Jan 2022 14:20:53 -0500 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 dfw.source.kernel.org (Postfix) with ESMTPS id 6804660909; Mon, 24 Jan 2022 19:20:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50C1AC340E5; Mon, 24 Jan 2022 19:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052051; bh=diNtmretYvBMH6ruzlzMmmbrIGYcwFDWMdE2r2P1wKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1HI3Iz7ElAW9yyU5C0nhQx0ykGNcWBeOolQtkRqFdJZW3W5HDDWfaZ64O0ohYqjBw YTNyGTtf5+g9lQLUG9zkJqjmJZUidkEEyOGc2XDGa6w8IZisUrH9dTHce4aX3dt2rg k69pymccGfzld1XFBshBv/OoiZctQsAiOLM+6yuE= 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.19 171/239] dm space map common: add bounds check to sm_ll_lookup_bitmap() Date: Mon, 24 Jan 2022 19:43:29 +0100 Message-Id: <20220124183948.538720161@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@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 a284762e548e1..5115a27196038 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