Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp273814pxb; Thu, 25 Feb 2021 02:03:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDQruBk5mfYgY2Z3UZxKJwLXwPNdyH4Hp7PyF6mbS9kqd1GE9IF4oot5cXRQuuVsN5jy6H X-Received: by 2002:a17:906:ae88:: with SMTP id md8mr1021783ejb.264.1614247383832; Thu, 25 Feb 2021 02:03:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614247383; cv=none; d=google.com; s=arc-20160816; b=bEdzfOtNAG3ZeGvfQtUZjAYADJwUa01U8Oub3xeAMcZo/izrmO4wXMUkKqlFVuz4WC OcQ+MYPCI/ucUXE8VHwEYTzYLoj1EpXXIwmzusSjdE0p/WcNz8Dzf0UIOzEt5SF5X/Us Kf6pHK8sQa66jVf60Fx34A15x/8rZMWkGOQ+pl39Re15YzpRvxcxpFDbPTc99xu2vcNn UItaMJd2GSCmWMuxITY8aIQ68HdQBCZZzAZkK0inIPrycX7eH9Gj/SzawvP6mq8nr5uZ RnMI2K0oTgs8TbzoaukXIwV3+VKoYZSZi5KwcPMCIBQLVR9NA+iyokqfwy2MftoFN8i6 Qqhg== 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=SqeK44lcx/3gOZzrAJPmH9uKeNvyaiV8zgnaiYJjOTI=; b=uD4bzjuopxfJsGpr4+SEVnShvRRF9AeJ5TGwVHZJY9M98W+7adeP29UnjszJm56sRx pH81pcwYhSd5odKtOmj4L90BivxWXhcx02YUu3mZ84Y8VoQXqnp5xnqAeptAU8clFa6T umMAadnHzqNz9j4eNdE9iIu4TCGvI/FeWeE5RvANZHBTAvTXtaadaN2p4OT9seEOMhgT W7uhDdylZlSvGSiLIBBQRpVh3gsDW0re3eF34S+iS1I74SRnIRlkTAO0xqfZ+72TPutI Gpjd8/kqD9HXhiNmeXl7/2RyqoDDGKmK9Zsa+hoBnJTYUzOry0339gvjLz62BRxT22TR Onzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EKoLLHcZ; 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 u5si2935823edv.181.2021.02.25.02.02.40; Thu, 25 Feb 2021 02:03:03 -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=EKoLLHcZ; 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 S235668AbhBYJ5L (ORCPT + 99 others); Thu, 25 Feb 2021 04:57:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:32772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235494AbhBYJyo (ORCPT ); Thu, 25 Feb 2021 04:54:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B3FF964EF5; Thu, 25 Feb 2021 09:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614246843; bh=iBNOvr58JQz924Lz8whUfoQyHyI302JA1X7nNfhZi04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EKoLLHcZEJJC4KJl4T/DJzipKsIWmulD/UNqWhOiH5X+KVOjGmvGBwsvI2OIUMRLd rnBiUCPVUr64QvWSX9hINUMBmRi/oT3qWTM2SxAYi5G1lJksMGVdhivzP7gJ5LaCQ8 hl845N330VO3oUW9mpwmJJ7rBRzg8UcmNx2a+XYs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.11 12/12] KVM: Use kvm_pfn_t for local PFN variable in hva_to_pfn_remapped() Date: Thu, 25 Feb 2021 10:53:46 +0100 Message-Id: <20210225092515.573855820@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210225092515.015261674@linuxfoundation.org> References: <20210225092515.015261674@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: Sean Christopherson commit a9545779ee9e9e103648f6f2552e73cfe808d0f4 upstream. Use kvm_pfn_t, a.k.a. u64, for the local 'pfn' variable when retrieving a so called "remapped" hva/pfn pair. In theory, the hva could resolve to a pfn in high memory on a 32-bit kernel. This bug was inadvertantly exposed by commit bd2fae8da794 ("KVM: do not assume PTE is writable after follow_pfn"), which added an error PFN value to the mix, causing gcc to comlain about overflowing the unsigned long. arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function ‘hva_to_pfn_remapped’: include/linux/kvm_host.h:89:30: error: conversion from ‘long long unsigned int’ to ‘long unsigned int’ changes value from ‘9218868437227405314’ to ‘2’ [-Werror=overflow] 89 | #define KVM_PFN_ERR_RO_FAULT (KVM_PFN_ERR_MASK + 2) | ^ virt/kvm/kvm_main.c:1935:9: note: in expansion of macro ‘KVM_PFN_ERR_RO_FAULT’ Cc: stable@vger.kernel.org Fixes: add6a0cd1c5b ("KVM: MMU: try to fix up page faults before giving up") Signed-off-by: Sean Christopherson Message-Id: <20210208201940.1258328-1-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1903,7 +1903,7 @@ static int hva_to_pfn_remapped(struct vm bool write_fault, bool *writable, kvm_pfn_t *p_pfn) { - unsigned long pfn; + kvm_pfn_t pfn; pte_t *ptep; spinlock_t *ptl; int r;