Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3547896pxb; Mon, 24 Jan 2022 11:57:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhGd+biwPPJJv2+kTg+cssjMUJZitIjYyudSYEI2KSayYFA4zH7A5wcqh2+4gBMHWRkp4J X-Received: by 2002:a17:902:e54f:b0:14a:48d6:d39e with SMTP id n15-20020a170902e54f00b0014a48d6d39emr16101834plf.123.1643054274917; Mon, 24 Jan 2022 11:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054274; cv=none; d=google.com; s=arc-20160816; b=K1mCRuy6abmj/k6Q5VUVNzOeV9kifGqJBWZRdapoC3qE11blKo5klW2laFI+HmeQ0n RHCMcOCgT/JsPSUNIzRtyz/QENq/wu7UOUSyLTHFvOwCrYSXis/f+7quQEnvVgZlnnTR gc5vLVOX3Q93prfJwH7IPYziQCLClz/1QPNrZpytEglseJvH94nncvyLYIHaDcWf0HR9 wXd5E0IRsp/7mjjmF83x+uwcBm2w/bwpUctXaIKXahq2NduiSEyT6sW6M/q9uSunzIrp oTMlRmVPEf891Zrbd3DVJmXas+GTnD2O1EsbhzjZ7Aprhe7g4xyWrIk9m5uCEqEnjaDK C4hQ== 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=BYuV6e2vLOdJjjvkZYMHEkhR3KGRXdXFhepDdy5DPdwdtVBAqxr9djnBja4P8p+gmS ANdS2FCXnUoOL3/aiBWYgWmZclVnvTk0v0yuyGTji75kXr+Rz2Y8yxryA5OzEUgnabYC OlVeHHdaLnlC3Q8k1NR/dxprWzBqWoAMxK84Yw9GaB23ERrLyYfSV/+7oK2GoTxT6ueQ /9stXC9ve4vuhwZ9A0+Xzz3c+7S+w+MdmNE4xebClPfpJszhzHlHz3g10dhtyTWyeiGk DLCZI4hoOfkDfVeBjZeIlCkAZ8i8mtz/BV7oRbSqpJZMXlpvB+4zGNqODOXUMSUsyUQs uwYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nX8iKJ20; 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 f5si5643379pgc.308.2022.01.24.11.57.42; Mon, 24 Jan 2022 11:57:54 -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=nX8iKJ20; 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 S1344171AbiAXSxt (ORCPT + 99 others); Mon, 24 Jan 2022 13:53:49 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:49716 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343517AbiAXSwE (ORCPT ); Mon, 24 Jan 2022 13:52:04 -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 01FEF614F0; Mon, 24 Jan 2022 18:52:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB91CC340E5; Mon, 24 Jan 2022 18:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050323; bh=PE5eRi3IE9VNLlQ1ed9CSr4cABoF8ehAGM5W/x8b8/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nX8iKJ20S5qK6FiN8tZR0g3XTlf0gRIIua4AsCabxCSFbriJtJSlMJpjDKmbk7wVx VHNr7KaqE5gMtlqTS/Cg6dLuUUphqdCZ41Ftmbm8FviK8RUmSyY6/SvhxtUrc+HwiD Yip3K2OB2tn3Q4Xlcg8W9y+nUolsZs9xC42/T01s= 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.4 080/114] dm space map common: add bounds check to sm_ll_lookup_bitmap() Date: Mon, 24 Jan 2022 19:42:55 +0100 Message-Id: <20220124183929.580137882@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@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