Received: by 10.223.185.116 with SMTP id b49csp1115519wrg; Fri, 23 Feb 2018 12:11:32 -0800 (PST) X-Google-Smtp-Source: AH8x225L3QSnqHbyfpnFUUSWNI/qJkhguvxUTMsJpQoM3lipIFKFIsR/G26GyyXD/oUdrsfBckOD X-Received: by 10.99.139.199 with SMTP id j190mr2336286pge.334.1519416692396; Fri, 23 Feb 2018 12:11:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519416692; cv=none; d=google.com; s=arc-20160816; b=GZK15aJEnhL9p+u9uJqeozdEv4NRDjUIgpMwlIeVTAdaPJbNWliuscOmJiMnTPZp/C P7alIEHATRcWYOTHsPGeZjrks9v1JLmfvTN+jzjOcOVyeaAvqJ/ZnYM5d7O8G6Atrthi OgYJ5aiDuq819pRg9eFf0gP90bHaESwcKSwAzTfmrkAp/d4G5ne8b9hSvZNbKX5sWets yZz9D1qX8BZ+fNZLuNKaRkFKJ+SR1H4OUdQBimGPS2Xp50AIfPYvUQLXtOpD9loQ0lnu c266oTondQLEzgUHS6brGiTrjYzhq64t+K5AgilWac7DQfZ6xRSiSG3edkP0SsOptbGQ q9wQ== 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=A5OWk5tT06K6Jds3zynDy/uZiNCqMbtRc+Y7Bn331cE=; b=akn9AEodyi5rH1O8X+1nbctGeNcLeWVsHqk5lBsCdQ5zryxTRKFOnMRnqJgxAhRAND TBJcMAGzh6PPLZZMHFh+wDMiJbXadrO+U2F5aNy/avR/Z3XPufEx4pO5+j+J6ZmOhRDq QaBswy9Nw+WV97lqePsHXiBU0Gm1Kw7VfEZQK0veohTdz15F/Q13+GwqM+6dixPxKLQg tQIRuhFeSnSKwHmOpn+duFj8PNDJ1NbB+4QkfNKp3EkYeSz1YcJx3+30VW0m4k7IRMB/ Id2tBuK36gI/sxRshlYPJ8kvCEQmDF3EGQ5IFql6cSW7e0pUTXR8C6VHccN0lYKjDlTm HmZg== 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 q16si2272663pfg.221.2018.02.23.12.11.18; Fri, 23 Feb 2018 12:11:32 -0800 (PST) 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 S932944AbeBWSls (ORCPT + 99 others); Fri, 23 Feb 2018 13:41:48 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40704 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932928AbeBWSlp (ORCPT ); Fri, 23 Feb 2018 13:41:45 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 901881214; Fri, 23 Feb 2018 18:41:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Mattson , Paolo Bonzini , Jack Wang Subject: [PATCH 4.4 190/193] kvm: nVMX: Fix kernel panics induced by illegal INVEPT/INVVPID types Date: Fri, 23 Feb 2018 19:27:03 +0100 Message-Id: <20180223170356.171796567@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jim Mattson commit 85c856b39b479dde410ddd09df1da745343010c9 upstream Bitwise shifts by amounts greater than or equal to the width of the left operand are undefined. A malicious guest can exploit this to crash a 32-bit host, due to the BUG_ON(1)'s in handle_{invept,invvpid}. Signed-off-by: Jim Mattson Message-Id: <1477496318-17681-1-git-send-email-jmattson@google.com> [Change 1UL to 1, to match the range check on the shift count. - Paolo] Signed-off-by: Paolo Bonzini [jwang: port from linux-4.9 to 4.4 ] Signed-off-by: Jack Wang Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -7361,7 +7361,7 @@ static int handle_invept(struct kvm_vcpu types = (vmx->nested.nested_vmx_ept_caps >> VMX_EPT_EXTENT_SHIFT) & 6; - if (!(types & (1UL << type))) { + if (type >= 32 || !(types & (1 << type))) { nested_vmx_failValid(vcpu, VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); skip_emulated_instruction(vcpu); @@ -7420,7 +7420,7 @@ static int handle_invvpid(struct kvm_vcp types = (vmx->nested.nested_vmx_vpid_caps >> 8) & 0x7; - if (!(types & (1UL << type))) { + if (type >= 32 || !(types & (1 << type))) { nested_vmx_failValid(vcpu, VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); skip_emulated_instruction(vcpu);