Received: by 10.192.165.148 with SMTP id m20csp532408imm; Wed, 25 Apr 2018 03:48:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx484I5lgIeMA4tyHs8tZKh72hYIxcmFttP96YX8Oz8V3IxjDKfrIN4Px8caZM1Nf5k5LoLau X-Received: by 2002:a17:902:a985:: with SMTP id bh5-v6mr29266434plb.0.1524653314996; Wed, 25 Apr 2018 03:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653314; cv=none; d=google.com; s=arc-20160816; b=ozaxqAEtyXaDE4xIUr8+XUsfKU7tSNj0V6ac7CfO91buw19L4IcHnGan0E/yF0h4i4 mmgL8BdCeACN5hfejmFVJgkUj6/J+j5n1OCnyOwLLnYui39nCZ4UmSDORsf9gbyWc5ir XnkbXpPpMA23kUj3m4v8AjPof8i6w7pAI+3P2FYcauDkmeINRckdgOO2UHB9ZMEN2ccT 9IGGGhHkv1wkHiO9n5nsvxqmuM74t08BA0nQOgm5ETAnK9GBiyLrnxjhLjbu5W03NIdL BUXQla4yZbE/9gMAGaLTMmdv9lvBF3EIqbuSsaXhL6BDJr+ejR0gHSE7+E97UfgW8KhL 5OCA== 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=tK5pCmL5d9Y3D3GBkLCmvdFtm48QLMksrXawUdFLaMc=; b=kWyC7TYKLwzPHzbqAa8o/6BOTi45dT2Z/Ne836H8YWXoF1mgi8WQBQ30TTU0chb5rv GzZEKlXFcrB5iM6TvelwBgE+Nj31lQrd6Zq7EXqDeCBGA/Ea3OILGp1AuWmTH3F1Zbke Bk/j5ZxX+iX3VC6jv8EXlrM055RAWyqvPo3DBrhXcrPaWj0zdRbChpPw9Q5GIM7QJyK6 5yywoYZiYS9ZP9QCJj+TpbpD7xit2rgFKcuhlo/2NIAxFQiJ4Ei8BdA4OqaMoq7Mygk3 woIkOesecd7z6AyWOnpLD5d/nfkXm5c9QPrzabvqHdWbbPs6Ovm5sGvLbyUkHm2vwbYt Hr1A== 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 r7-v6si16549939plo.486.2018.04.25.03.48.20; Wed, 25 Apr 2018 03:48:34 -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 S1754372AbeDYKqq (ORCPT + 99 others); Wed, 25 Apr 2018 06:46:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53462 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754478AbeDYKo7 (ORCPT ); Wed, 25 Apr 2018 06:44:59 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 90996412; Wed, 25 Apr 2018 10:44:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini Subject: [PATCH 4.14 182/183] Revert "KVM: X86: Fix SMRAM accessing even if VM is shutdown" Date: Wed, 25 Apr 2018 12:36:42 +0200 Message-Id: <20180425103249.812470292@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@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 commit 2c151b25441ae5c2da66472abd165af785c9ecd2 upstream. The bug that led to commit 95e057e25892eaa48cad1e2d637b80d0f1a4fac5 was a benign warning (no adverse affects other than the warning itself) that was detected by syzkaller. Further inspection shows that the WARN_ON in question, in handle_ept_misconfig(), is unnecessary and flawed (this was also briefly discussed in the original patch: https://patchwork.kernel.org/patch/10204649). * The WARN_ON is unnecessary as kvm_mmu_page_fault() will WARN if reserved bits are set in the SPTEs, i.e. it covers the case where an EPT misconfig occurred because of a KVM bug. * The WARN_ON is flawed because it will fire on any system error code that is hit while handling the fault, e.g. -ENOMEM can be returned by mmu_topup_memory_caches() while handling a legitmate MMIO EPT misconfig. The original behavior of returning -EFAULT when userspace munmaps an HVA without first removing the memslot is correct and desirable, i.e. KVM is letting userspace know it has generated a bad address. Returning RET_PF_EMULATE masks the WARN_ON in the EPT misconfig path, but does not fix the underlying bug, i.e. the WARN_ON is bogus. Furthermore, returning RET_PF_EMULATE has the unwanted side effect of causing KVM to attempt to emulate an instruction on any page fault with an invalid HVA translation, e.g. a not-present EPT violation on a VM_PFNMAP VMA whose fault handler failed to insert a PFN. * There is no guarantee that the fault is directly related to the instruction, i.e. the fault could have been triggered by a side effect memory access in the guest, e.g. while vectoring a #DB or writing a tracing record. This could cause KVM to effectively mask the fault if KVM doesn't model the behavior leading to the fault, i.e. emulation could succeed and resume the guest. * If emulation does fail, KVM will return EMULATION_FAILED instead of -EFAULT, which is a red herring as the user will either debug a bogus emulation attempt or scratch their head wondering why we were attempting emulation in the first place. TL;DR: revert to returning -EFAULT and remove the bogus WARN_ON in handle_ept_misconfig in a future patch. This reverts commit 95e057e25892eaa48cad1e2d637b80d0f1a4fac5. Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3019,7 +3019,7 @@ static int kvm_handle_bad_page(struct kv return RET_PF_RETRY; } - return RET_PF_EMULATE; + return -EFAULT; } static void transparent_hugepage_adjust(struct kvm_vcpu *vcpu,