From patchwork Mon Aug 16 13:02:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 497660 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp91840jab; Mon, 16 Aug 2021 06:23:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRg8TWFaGdiCKxWMC819ZA+dqXiNCOkp1zBfdl33kBlDHzDOkhFeJw2WvQUz3dRfbnC1WK X-Received: by 2002:a17:907:86ab:: with SMTP id qa43mr9335812ejc.224.1629120092486; Mon, 16 Aug 2021 06:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629120092; cv=none; d=google.com; s=arc-20160816; b=yjmw24eFg5JNennWnA3mc4YP9tAo3FF+sOXj+1cXtEHJ5Dg9Zv1aclMt3JrtQiIynn mzuaARdbzP99w+odgbLxaT0oFpsOS9a8J4II49KV+lcqPduf60sLr9GqXkVqrhZpPGKv SgUViPiysARXwL2DU/SGkZeDJ+1RtcUzbxSPogxMjx3pFjCeAgIAZTQ7tC92OL7c3Uzn L49KFnsjdfPxF+X74U506vNV2KaQq9zK+ZiV/XL0X0fCTdo+kEkGZLfvBId0uLFyKcCN +u9bzerL1DZsAh3HE8wLzU3u9KXjXP3B2eIJ1qMlGYHLhx+yOlzQ0gCCXntP1mDZ6la9 yNyA== 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=DEbc6sHw3R7oMNQ7maeFzxrhBij9zZTgN0lvI/RAntE=; b=w228eVrCZhRp959b7t7LA3lJMc1Md20W96Suuo7IljzjbfS5CruzBL06pi4QqRM9FK PHIoLWZXVkexkWA3ebFK18Z2QUDGim7HnrKpVE27HoIERFPrdfVkoAjWWo1E7c9Aq8yY eR6z/PIc+A9rpnx25cPFQ8HZGc+ZZeDshDgmY65tEdhM+nEUMeUi1864XLuans+PuF+I cgedZVa2YZe0WtRGO3B83uaNdaRVw3MjROdALMW3pncajpP7+vuUQv7pQNU6B6s8gPqF 4azNX/vRZsLdOO7gVrCKZhVtDi/hfAmij2neJlOYH10P7PtXe4l2flyIHCzMNq4N5cod xjqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wf58Mwn6; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 z7si3420761edc.144.2021.08.16.06.21.32; Mon, 16 Aug 2021 06:21:32 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=Wf58Mwn6; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S236669AbhHPNWB (ORCPT + 12 others); Mon, 16 Aug 2021 09:22:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:43336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239145AbhHPNSq (ORCPT ); Mon, 16 Aug 2021 09:18:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A73226323B; Mon, 16 Aug 2021 13:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629119668; bh=91cMfIzDPzFLBPH9m4BAoqY/R69kSyAYdxpOmr0aVr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wf58Mwn6j+cG6p0KS42clVIwhxeknJ85ZHBg/SqA5FIoDvStI3pZoUA0S8QVjoJM8 KM7Lm3AiwpmFmEOdrEddBclLBrae6UyRz8skdkizBkR8UGhiVaYcoJSJg7evgIipfp c5YXj7Nl1OL41udbjz5seBU9f2K5dZEN2qlctDvQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Quentin Perret , David Brazdil , Marc Zyngier , Sasha Levin Subject: [PATCH 5.13 115/151] KVM: arm64: Fix off-by-one in range_is_memory Date: Mon, 16 Aug 2021 15:02:25 +0200 Message-Id: <20210816125447.850735164@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816125444.082226187@linuxfoundation.org> References: <20210816125444.082226187@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: David Brazdil [ Upstream commit facee1be7689f8cf573b9ffee6a5c28ee193615e ] Hyp checks whether an address range only covers RAM by checking the start/endpoints against a list of memblock_region structs. However, the endpoint here is exclusive but internally is treated as inclusive. Fix the off-by-one error that caused valid address ranges to be rejected. Cc: Quentin Perret Fixes: 90134ac9cabb6 ("KVM: arm64: Protect the .hyp sections from the host") Signed-off-by: David Brazdil Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20210728153232.1018911-2-dbrazdil@google.com Signed-off-by: Sasha Levin --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.30.2 diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index 4b60c0056c04..fa1b77fe629d 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -190,7 +190,7 @@ static bool range_is_memory(u64 start, u64 end) { struct kvm_mem_range r1, r2; - if (!find_mem_range(start, &r1) || !find_mem_range(end, &r2)) + if (!find_mem_range(start, &r1) || !find_mem_range(end - 1, &r2)) return false; if (r1.start != r2.start) return false;