Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3715739pxb; Mon, 24 Jan 2022 16:09:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMKWt0bFhAkfanKeLwYMFfYKfu6aBNTjHM2Roha8b2bulr4f1JqXfwts3yXK/sZ/4iA3U9 X-Received: by 2002:a17:903:2284:b0:14b:2764:8ffc with SMTP id b4-20020a170903228400b0014b27648ffcmr13242349plh.35.1643069372421; Mon, 24 Jan 2022 16:09:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069372; cv=none; d=google.com; s=arc-20160816; b=fWqlrPPnaZcAYgwi67AbcSiGRmTXbma1bxZWyRHLaXd7Pg22A3d/G6Re57SxLxM79f 4z9Sv2G9xEBHZRKZbRG6bHp/+C8HV3P9VcSO8/Q7dD5xI1Monmvfts5XhRT4hYr/9ger EXdtPZJGz8yc0lMN/mtZvtIACc99C+hO79jlP/xkToCMOlMDpr3p5z311bgqe8GR2Kry tj+nPb+w+HDjNXL930xDj6xDyOePplzbpHcs9LkOCvJqyS+8ffZwG7G1zCAjof47xfIR wDKB3GwoyaXUY6Co2DzlzFu/rPLU09hrk1wKoTGnQk7nEfFVKfCCfq+ob+Iv0eQQZB3O 1VmA== 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=pe+yKs3qxOrtnJinP70vsHX+3GCytEZMyy/18fQxjbe307iDT8WE3ovXivpEhr55JQ 0QN1ccnGhVCc//6kDuqD4lIzRERAizJrBlOhITLL3tjTYFrkmFLJNoQpyT45Gk8s6TA6 yOpfmzUXEQMKNeKNbvqk6CUA2pp0EyZB+Mw4d9PgKD8teo5WtTJ3h7FCYvWV6kCJo1Pf suY9BuPF+AuC2Yxl85OJ55kohB4GER6LodN+6NV5bT8vM8UfWq7NHKFblsHvER8DqYG2 Q/WwcFuvdKnAdHkd8eenG7g/Vlsv1AikJ5I5vVZSXxzlq1StHfUtQ8scJjr4+hE1+LIa yymw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jm7gwoBS; 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 s15si8900942plg.141.2022.01.24.16.09.19; Mon, 24 Jan 2022 16:09:32 -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=Jm7gwoBS; 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 S1385187AbiAYAHn (ORCPT + 99 others); Mon, 24 Jan 2022 19:07:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1848236AbiAXXWB (ORCPT ); Mon, 24 Jan 2022 18:22:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0388C0219E6; Mon, 24 Jan 2022 13:28:51 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 7073E61320; Mon, 24 Jan 2022 21:28:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D476C33E61; Mon, 24 Jan 2022 21:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059730; bh=+j/hF9KUbkWpVpF0TWD+CJhI+JZR0eec5rq0R+03JEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jm7gwoBSmtArZ6qliUrCFMhWvZ1s7Zd0QK19u/VKyzZHPRYpcBk7I3CORfEBHFISd HnEPQPjBKiVRlbPeM5Xb/kh+yzbiM7PNM7knBL/ZwbWmNdBsjoZBmY8huuJpd38veN QUZW+lbujX2Z2xZ4m1DLHy8sW4uMAjfOjEMY6YlI= 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.16 0714/1039] dm space map common: add bounds check to sm_ll_lookup_bitmap() Date: Mon, 24 Jan 2022 19:41:43 +0100 Message-Id: <20220124184149.335514594@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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