Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1821441imm; Mon, 3 Sep 2018 10:18:01 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb/dFX1FtllnQ4dvSopIcKqtB2H5jkyJtEmpG2YMurN1FluVMUSRjfQ2wcInA7/AXkN3AzR X-Received: by 2002:a17:902:6b83:: with SMTP id p3-v6mr29741179plk.133.1535995081276; Mon, 03 Sep 2018 10:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995081; cv=none; d=google.com; s=arc-20160816; b=eG7RgE0CFiPcwviNpZhkrtFdgPDyAKOeYhDGZqgPwvWYYMfNzUpm/NgSXXL+nkI8cQ NFayMRyH3g9Omi16c8HyXtN0sRqjYhlR96omxDmAwKfWcC7fMKod7f9o5VxmJ6jEXXD/ 5dBMffIcje2oMIVAXNACLKx86wAEvOp2z/Sp7VvWgVXUQ6yxwyqXlCQpwGP4rXbFm8ML qFj7GUD06WYj8JiGlK2WCzTJrcIbhdjqfY+YCrZ7LkORXlpO9v4HrShbjhJcTL18RLta TpgdSMFE9/g87R4Oa09YcxB5qa4a9JJ2rDirurOd8hAz28LP22gl5pZM84rI3RObOyPT ZNZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XYtWJnWvG6pu54uuxyx99EzhLUm+uSfs2PrJp8qmjqA=; b=wV8WCEiH/Qdm1j/8Rk34gpnEpJariWseB4l3g8cNNCI9sryGGJgwgnsvmQ7GnKq/I4 OURI/T5ISQJQYu5tcTJwDwrUq19bx4f9tAvpzqoXtHmmiBYTVcNi4cT7K/KxAwNXhePY eEQshbfvG9nf+wen+ouDsEiSUU5TifoqusJ4hj4hGFtlQdmytnxG+FLeU3bBZD3ZSM+R QOzwdMqpLN2E0Ta1EAb55tJTWXO1Di5pNypuWrhDBvPRSwUPHGi2stBfmYbWsYFfsyvL XfPZzI7C1QKsiZcNdntLNiizbYLbXg2+4E8DUdfU1Mgv38ZCHNrXsmtgLpbQsyrCVaT8 Esgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x188-v6si19242408pfx.19.2018.09.03.10.17.46; Mon, 03 Sep 2018 10:18:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729986AbeICVho (ORCPT + 99 others); Mon, 3 Sep 2018 17:37:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42614 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728036AbeICVhn (ORCPT ); Mon, 3 Sep 2018 17:37:43 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 419FAD02; Mon, 3 Sep 2018 17:16:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Peter Shier , Paolo Bonzini , Sasha Levin Subject: [PATCH 4.14 031/165] KVM: vmx: use local variable for current_vmptr when emulating VMPTRST Date: Mon, 3 Sep 2018 18:55:17 +0200 Message-Id: <20180903165656.655632955@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sean Christopherson [ Upstream commit 0a06d4256674c4e041945b52044941995fee237d ] Do not expose the address of vmx->nested.current_vmptr to kvm_write_guest_virt_system() as the resulting __copy_to_user() call will trigger a WARN when CONFIG_HARDENED_USERCOPY is enabled. Opportunistically clean up variable names in handle_vmptrst() to improve readability, e.g. vmcs_gva is misleading as the memory operand of VMPTRST is plain memory, not a VMCS. Signed-off-by: Sean Christopherson Tested-by: Peter Shier Reviewed-by: Peter Shier Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -8108,21 +8108,20 @@ static int handle_vmptrld(struct kvm_vcp /* Emulate the VMPTRST instruction */ static int handle_vmptrst(struct kvm_vcpu *vcpu) { - unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION); - u32 vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); - gva_t vmcs_gva; + unsigned long exit_qual = vmcs_readl(EXIT_QUALIFICATION); + u32 instr_info = vmcs_read32(VMX_INSTRUCTION_INFO); + gpa_t current_vmptr = to_vmx(vcpu)->nested.current_vmptr; struct x86_exception e; + gva_t gva; if (!nested_vmx_check_permission(vcpu)) return 1; - if (get_vmx_mem_address(vcpu, exit_qualification, - vmx_instruction_info, true, &vmcs_gva)) + if (get_vmx_mem_address(vcpu, exit_qual, instr_info, true, &gva)) return 1; /* *_system ok, nested_vmx_check_permission has verified cpl=0 */ - if (kvm_write_guest_virt_system(vcpu, vmcs_gva, - (void *)&to_vmx(vcpu)->nested.current_vmptr, - sizeof(u64), &e)) { + if (kvm_write_guest_virt_system(vcpu, gva, (void *)¤t_vmptr, + sizeof(gpa_t), &e)) { kvm_inject_page_fault(vcpu, &e); return 1; }