Return-Path: Received: from mail-dm3nam03on0090.outbound.protection.outlook.com ([104.47.41.90]:18400 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032136AbeCAP3j (ORCPT ); Thu, 1 Mar 2018 10:29:39 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Andrew Honig , Paolo Bonzini , Sasha Levin Subject: [added to the 4.1 stable tree] KVM: x86: Add memory barrier on vmcs field lookup Date: Thu, 1 Mar 2018 15:24:06 +0000 Message-ID: <20180301152116.1486-158-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Andrew Honig This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 75f139aaf896d6fdeec2e468ddfa4b2fe469bf40 ] This adds a memory barrier when performing a lookup into the vmcs_field_to_offset_table. This is related to CVE-2017-5753. Signed-off-by: Andrew Honig Reviewed-by: Jim Mattson Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index a3bea4129cbc..23d5c2fc7573 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -772,8 +772,16 @@ static inline short vmcs_field_to_offset(unsigned long= field) { BUILD_BUG_ON(ARRAY_SIZE(vmcs_field_to_offset_table) > SHRT_MAX); =20 - if (field >=3D ARRAY_SIZE(vmcs_field_to_offset_table) || - vmcs_field_to_offset_table[field] =3D=3D 0) + if (field >=3D ARRAY_SIZE(vmcs_field_to_offset_table)) + return -ENOENT; + + /* + * FIXME: Mitigation for CVE-2017-5753. To be replaced with a + * generic mechanism. + */ + asm("lfence"); + + if (vmcs_field_to_offset_table[field] =3D=3D 0) return -ENOENT; =20 return vmcs_field_to_offset_table[field]; --=20 2.14.1