Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1730792ybe; Wed, 11 Sep 2019 21:21:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqySdl2HiraxDLhVoPy+zMdGHrMhNByIdsF14UW+VJmajpb6/LXOsLgGrCJgp6mQU52e1toA X-Received: by 2002:a05:6402:160d:: with SMTP id f13mr40099051edv.227.1568262060436; Wed, 11 Sep 2019 21:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568262060; cv=none; d=google.com; s=arc-20160816; b=A6N4I14Y79yNM0JiCifJi+drD/yLO2lGTFBj7kwxLWt2yXibUEKbWjPm7o9mKivDhL 9vbIluGbBLdlF71kp+oJkWMQL30ohJarPLZcu79J6Bgyoq0jVnWnF7CHcZPPHHhxYCXA Hoo/FI/il1qO9xr6rYZSywv4qd4hwQxMfgo0/HzCdt0939/KdH48cbuE8ykfSZivWS4Z hxwQZnUptCmZ01XWwjZYY4vM5tgqJHCeLA7RfEX7lgT5bdXcs1vNiFrOZaepfnt+1BsY wJtIJZAxax8eGZL5ARbwqc7GLcFfszSc8lLtOQ4C7EGxUO/inIblqlR77C3Lg+ola5aM oliA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature; bh=E78vnhmo9W2A2pNvQXFwnY+byAZLb8i8u9HyT6B3+sg=; b=l76Pdb4lcse0NIWix+hndveHyJMiOXRIn9Y74H3ucMHn6ReW7EoHUqBZnK+R9zd81c rKrg9yCth+8AekDenrWBsTj484tkjeZlvqcDg1Ozz4wqvicDf9/EaNvgTulq47hxJ1Tv OS61TIijJBHD7gV5aM86Bf0cNXZuRTwWRkp8EXtY8xNJoI3wqvLazzPD7QRUNkit5Hfa 6qchUFjJkwxq+06tvo+E8ULoCSbPUkolatL1sanecP2J7dJ7LnBesQBOTaS5jFdftk4W YDeTZNpOWk/A3xbElTKneAYbAkj9ZgqIv+sewGzFAc/Q5l6IalpN1eTqzYhy0pH8O9PK 668g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=EKPvBwH1; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si10539628ejb.49.2019.09.11.21.20.34; Wed, 11 Sep 2019 21:21:00 -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=fail header.i=@gmail.com header.s=20161025 header.b=EKPvBwH1; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726458AbfILESf (ORCPT + 99 others); Thu, 12 Sep 2019 00:18:35 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46384 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725792AbfILESf (ORCPT ); Thu, 12 Sep 2019 00:18:35 -0400 Received: by mail-pf1-f195.google.com with SMTP id q5so15061736pfg.13; Wed, 11 Sep 2019 21:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=E78vnhmo9W2A2pNvQXFwnY+byAZLb8i8u9HyT6B3+sg=; b=EKPvBwH1+59k/jwqQdsSvQbO8k61IoR8he06AzVrsrO2S4NsaDCQj+9qXT4ifH95cA lStBOgUpKwZfOPXfuGwErlIXnIf/aTghhPz2KtzOPfGKEYQdagLqeEl2SZblxyZyEi/y RJmZb3iNgY5moYjUmvTiBw3ZeH3iD7braVQTDPznhRRcb9erM3N58YcaRlFwdlouj1A2 nJpUVWNaCxbcbyJWc6HBs9Jeixb6LN2WjIFQpokWLIC8jXxd94OX+rP07KyEyZnZzUTU P0isEghZmhMU+1GBOygU1Ty4hoKqkfrs8qNbn2bEAlyYpWY7+Ir7lKSzpd48ghOnlA/d IbgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=E78vnhmo9W2A2pNvQXFwnY+byAZLb8i8u9HyT6B3+sg=; b=LKJC7ut/fOCK9o2wG2ZuE0up0ZA/W8MZX9TkzdvrM6F6WVnBfapnQtinooxfjDvS/E V//8Xw/Ulwh1mBTNckhy/Zp2vXyDLqYlzz7skOuTOk9vkXLHi+gBvQsKjTFnA5SOHX6L 4n0zBEYm7H24ojvjyj2q/joyj7XBlIQRf61myF/0NR8VfbcyfHOIS5lhzomtGhR/ExI6 4A9xbgHFryY7ngwZFHl4GmjI4CGRM9NMWauMOusBebNFfmNVJfJtst0mBHVennKcqNgz DWbZ9JQh+K6qsOj2u5TmGDaIKsJltmfohMYGfeKXzpOUObxNbMZ+7MLpmq+q2CZdO2qg cOQg== X-Gm-Message-State: APjAAAXJ1tbxikzCrgfG8zFY6y0aS2r7+2VVLm/DzyZblKU5PLr38DBE /eBE9yrc9HtPoieK/A88ebs= X-Received: by 2002:a63:fa11:: with SMTP id y17mr36421144pgh.267.1568261913071; Wed, 11 Sep 2019 21:18:33 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id s4sm24278875pfh.15.2019.09.11.21.18.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Sep 2019 21:18:32 -0700 (PDT) From: Fuqian Huang Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH] KVM: x86: work around leak of uninitialized stack contents Date: Thu, 12 Sep 2019 12:18:17 +0800 Message-Id: <20190912041817.23984-1-huangfq.daxian@gmail.com> X-Mailer: git-send-email 2.11.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 290c3c3efb87..7f442d710858 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5312,6 +5312,7 @@ int kvm_write_guest_virt_system(struct kvm_vcpu *vcpu, gva_t addr, void *val, /* kvm_write_guest_virt_system can pull in tons of pages. */ vcpu->arch.l1tf_flush_l1d = true; + memset(exception, 0, sizeof(*exception)); return kvm_write_guest_virt_helper(addr, val, bytes, vcpu, PFERR_WRITE_MASK, exception); } -- 2.11.0