Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6240152ybe; Tue, 17 Sep 2019 23:37:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6Sjw3j7PuyplaBoAJ+lw2nU73KucdWUJFLVPkPLwU/oq36o6zYY9uub3bdujQ/SZTfWHi X-Received: by 2002:aa7:d988:: with SMTP id u8mr8611008eds.116.1568788638430; Tue, 17 Sep 2019 23:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568788638; cv=none; d=google.com; s=arc-20160816; b=iEepymuoHDqVdhrRZrkH1iNAtrxG7oXD9Ku3LnByBVUZaGvdnoB+lpxzYFC4ZPaBLz hlGfq3wwr4dtHTuRaPZp6GKSAxoLL87SnvSh2LUFWRSm6qKufAU9CCrNDoTLfJ2vDoTx eP/8ajC/iTXUdhEwn5vSYfAkBmyiWGhl/VDjhmlAc/xELaCzRVkD6zarsKKq6LTznBUj MFm9hG2EKb+Khx2idqaqvG5LpfcLR1aTF1IQs948Q1xLLB5vkmCW2rl5XTgKvemE03QF 82q82mCDLpLv2XmfJl0kOfweKNRh82Jc0cYEoVzd5sOmyNcD4gx8KU79GONfZd93iK9s rKxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XTCTsDtxwdRUDpPz/n0Ig+LCQ8Vf0Mb1vJHUFHEZ/pE=; b=IVSX+iIJC3d9bBumFei9v+aEkobSKUqFMH/r2kQ+6RPQuTl1go6gLaqIy9JxXek1a+ DiKdfEvVNus29jSCpwTUNtVFy3C1frSgomyHIKMspfyBsmePnNJ6kykskMfqcnW4bZLX dSTZ3jdJ9CBQHL+uBFbkn7pCHoQQzk0bX02dVIxabAK8/Doks535tpYQzZLsHEkeCzm8 yVQVRUJhWjdqV3Pji3SDsnzdA77lVXwSJsam7QVCVlWoHZ1wl7exFuLMDOEHF2+0KT3L +ieaKSbBZJHv3H9BlpFjdzfxYRoeX4Y8uvKi5dObhYUnXKXw1TYdYcufJYfqLkugcaa5 +wQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JKD9q5Tt; 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 d25si363909edq.65.2019.09.17.23.36.55; Tue, 17 Sep 2019 23:37:18 -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; dkim=pass header.i=@kernel.org header.s=default header.b=JKD9q5Tt; 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 S1729464AbfIRGWn (ORCPT + 99 others); Wed, 18 Sep 2019 02:22:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:42738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729459AbfIRGWl (ORCPT ); Wed, 18 Sep 2019 02:22:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B94FD21920; Wed, 18 Sep 2019 06:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568787760; bh=wAx23GSFUcnVrM32JI4TGHRW8JL6phpNBAgxKz3VXyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JKD9q5TtQDfkPWi0fF9vGCVfsCruOY6x/y+YLUBC4pGqOkgtL8AEspTbkKWtTb6rt GNsS7ncJkQBzWfLH1RCOFXDp5vzmPbDXHMapJ/zzi9J+mzS/Q9ToT90P7ibSGGdVqo YDEjVY09RMVNMsIqxPLJdXned46+HFi3PNqv0dAo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fuqian Huang , Paolo Bonzini Subject: [PATCH 4.19 23/50] KVM: x86: work around leak of uninitialized stack contents Date: Wed, 18 Sep 2019 08:19:06 +0200 Message-Id: <20190918061225.490523369@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190918061223.116178343@linuxfoundation.org> References: <20190918061223.116178343@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuqian Huang commit 541ab2aeb28251bf7135c7961f3a6080eebcc705 upstream. Emulation of VMPTRST can incorrectly inject a page fault when passed an operand that points to an MMIO address. The page fault will use uninitialized kernel stack memory as the CR2 and error code. The right behavior would be to abort the VM with a KVM_EXIT_INTERNAL_ERROR exit to userspace; however, it is not an easy fix, so for now just ensure that the error code and CR2 are zero. Signed-off-by: Fuqian Huang Cc: stable@vger.kernel.org [add comment] Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/x86.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5016,6 +5016,13 @@ int kvm_write_guest_virt_system(struct k /* kvm_write_guest_virt_system can pull in tons of pages. */ vcpu->arch.l1tf_flush_l1d = true; + /* + * FIXME: this should call handle_emulation_failure if X86EMUL_IO_NEEDED + * is returned, but our callers are not ready for that and they blindly + * call kvm_inject_page_fault. Ensure that they at least do not leak + * uninitialized kernel stack memory into cr2 and error code. + */ + memset(exception, 0, sizeof(*exception)); return kvm_write_guest_virt_helper(addr, val, bytes, vcpu, PFERR_WRITE_MASK, exception); }