Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3560487pxb; Mon, 24 Jan 2022 12:14:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYc5CVhg9KPUoLuhqcpne1S76noFr42x5qUuq/PO+DzlCdaMvtsfqMJw0fVT5KmAlsxMiR X-Received: by 2002:a17:902:ce91:b0:14b:42a0:8adf with SMTP id f17-20020a170902ce9100b0014b42a08adfmr8460020plg.1.1643055244456; Mon, 24 Jan 2022 12:14:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055244; cv=none; d=google.com; s=arc-20160816; b=fTpc3wVgXd8MD0nDeLlXMMdPlj96PtFegAv1YWHfs2O3sRc/JfWev+0kb746YFEn+x lAclAYkxP00K8ku3aFCQIlUlIJqwDfnaA9gn7jHphfsED131o+aiptWsiIuoziRhr/P+ 69RcW6MVB4ORGV4KStpcjGvtAKTEseun6zLZ3LatnSqzE3FeFqWYIOFeMLuOe/sdHKLs vLxIvptNXcOCBsUsnCvf4MGAgj+QLtDWwkAGoofvzvm423R2I0RfIZXrf5PFsFkZkGwm ngZ1fh8gwpYL+dR0PbR6KFSS6l/m0F8feXEyCIU/S2Ds9ob5G4evo4WhYTmmR28V+qLP g1vg== 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=kTmHaDs8lWvKvjqhDiTYam7abor7Q50Ds5JlCRKi6Os=; b=PgHP/AK+pPxReZSY0IFkV1i8vL0u2j2d995n6ygGnFq0e5Ma8a1JbJNjt5BxsGeV8e +T7V4T+spPy1YkjVATM9Vo0DBcdaBftRVcIEJpARETlt/tktA3zJwKQsJQ5MGvjedmBk bVBB0MkRFUFwvr2aNTwjxqHHDnnHlt5KNxPjkf0OX2h/crCs21Br87lG9wBH8ZgddcdG OD8vMOtn0/7MYUrIa8E5MUnHV6xcbz/4U1UrsWp64x/agwVkFlEAhIidm3d+bTV+WqKR XvSV+PyGuWYyN54XdNDsDvAKgOEPdz/24jYZs6a2Hy7cVlLKL2s7y/P3gO13FuLvphxh W3yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XNtbOkU5; 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 j6si8042689plx.191.2022.01.24.12.13.52; Mon, 24 Jan 2022 12:14:04 -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=XNtbOkU5; 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 S1347486AbiAXTQw (ORCPT + 99 others); Mon, 24 Jan 2022 14:16:52 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:38610 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345227AbiAXTIx (ORCPT ); Mon, 24 Jan 2022 14:08: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 E764F60B7B; Mon, 24 Jan 2022 19:08:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7EB2C340E7; Mon, 24 Jan 2022 19:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051331; bh=3pko/fty3e1jkvDU+lcK2yAE20crUsN5XxWJWc2HQzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XNtbOkU5QyDqcdYKNE14UXxfyZluNHUn8TuksO3QeUmbyQNjpHZrXvjlZWesPKCNM oZ4TGr20JfQctIMsLBRF+ZM94KabjTdf1dCQlMgVs55EXSVkBcbWVRYESRQh6a/yk1 dxNyeRC7gqLu8n/vv+rOuRTI2wDWFGO/8p/SzN8g= 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.14 127/186] dm space map common: add bounds check to sm_ll_lookup_bitmap() Date: Mon, 24 Jan 2022 19:43:22 +0100 Message-Id: <20220124183941.195964703@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 a2eceb12f01d4..1095b90307aed 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