Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3564869pxb; Mon, 24 Jan 2022 12:19:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoLHi6ACF/OCRzBCxpbob+JL+gk1qd3G7JOfRX3AOx21rqa7WV+hcJRduFTrPrPmZYpS9O X-Received: by 2002:a63:8543:: with SMTP id u64mr8456267pgd.338.1643055477074; Mon, 24 Jan 2022 12:17:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055477; cv=none; d=google.com; s=arc-20160816; b=jFDB47WpkwIv7q0z7Y9E9klNNzh5OtrstLaWcGsDWMLJETmICDCNIRD7YOV+LJGpNY EuXrQ3H+1UN99AAPWiO2OBE8I70yRMJgdbvgD9ZJTcX5XM+crE5XTiGhLZPAJPjIGD+H Xu8lisB0gTswXsSMoedxs/52i9wLz+WIteUXBc/uOZ+I/QTOWx0ArSD/zq3Ah9DUHqls 5u93Oi2B/8NF8vRAOFGwEMCszpLN2HhHHgzdEpnVT7bl6lpXyNM10W7bvmJCmGvy++ri +9/BMbkopceOQTWBq5Bgagm8DYfeV0mwDTRWmfGsQJibpBjoAjqMiykwm+YPusbezVXl gyxw== 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=qI42HBOhqkTuGQDxw71r+grVaGojL3sUdsb3TfDv1qo=; b=d/4jQ0QJUnMzKUOzuB7c67+d74yyLGlW/nNs1R144mlynn3PlIkNK2VKaHiqrkeQ9s xiArkj1aSLgeSQtqFM7jVWWd5r4J2VLNeHty3elSCPVolakOT7ws84qyzJFfOBuOg4hp DDLAmKiyxRyO3zMOy8uTGyq++XCwAVwEm5g9hImnaR3EM++cNrzFt+KSJJ4zG2iEEQt5 Kv1D28ZQj5LnjH7MRiSB1BBOgHaSe++jNDy3TdpOqQMRx8hQ+fPEsh4GvPw3MkZCEYTL /vFaGeaPxa6l9rBgaiqOa3k1mb97LwpIONwFmZ5oKpF4sAZEw2KbuiA1xYn3hjWnTDKP Q8KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2GPPgn8T; 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 o9si12195161plc.601.2022.01.24.12.17.44; Mon, 24 Jan 2022 12:17:57 -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=2GPPgn8T; 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 S1349282AbiAXTUb (ORCPT + 99 others); Mon, 24 Jan 2022 14:20:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347729AbiAXTLG (ORCPT ); Mon, 24 Jan 2022 14:11:06 -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 03CB1C08E859; Mon, 24 Jan 2022 11:02:33 -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 9753660BA1; Mon, 24 Jan 2022 19:02:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EC85C340E5; Mon, 24 Jan 2022 19:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050952; bh=lLizqx2R7dEZHunY5+u8UHZgY3PhUH6NOT0/2mmLldk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2GPPgn8T+zqhbrrJdteiZRalR3kG6OFIyyOBEcpe5N3BTN6bjIHxi/ce+A+VykPm8 VFunTvtr/g0UqRQuwrN1tXJkbMpIYQhjjq8t7L0Gbtg3Tc1WAvisId1xO2ZJ8Zz4ip y1S6vJXV57Pkema3aM4n0F2oPqmXrw4NVUK0kNlM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Sean Christopherson , Paolo Bonzini , Ben Hutchings Subject: [PATCH 4.9 156/157] KVM: Use kvm_pfn_t for local PFN variable in hva_to_pfn_remapped() Date: Mon, 24 Jan 2022 19:44:06 +0100 Message-Id: <20220124183937.704306868@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183932.787526760@linuxfoundation.org> References: <20220124183932.787526760@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: Ben Hutchings 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 @@ -1518,7 +1518,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;