Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp696105ybm; Thu, 28 May 2020 12:51:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPi5VhBMi21BYNBkY3qVkQcYsPQgXF8oowA5B2L50F562XRjo/CaN7GT4YUhv2aHzvlggt X-Received: by 2002:a17:906:b251:: with SMTP id ce17mr4258887ejb.165.1590695494070; Thu, 28 May 2020 12:51:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590695494; cv=none; d=google.com; s=arc-20160816; b=D0urDqwGl/kXiHqXxCW2bQFzyzgA6hD0U0Aa/72SX1gg6N6ZQS0jabpTfxudT4Dy0Y 0CTUkMDqG9DH83HLbghJEz9/9j6D0pnNtk+1ricaGxMLKPM9HHp/xqwopqgye6PNDern RXUZ83C4zFpHvgmeluYq/rbOKN+vn8r1d4olXmnsXYQfVSnrWkqmlPj8NKB0sJMOoXGM VpxL9qUebBICGISWlXAutMlLR54thkbcc+BQACzlYaIGv+g56ocS/evvolm5O9XNdujT TnwEnqcYXo503rHds6acWz5ihFDJO10Z65zZbzufSK4lLf9awOMlelsrO530VKaf2aLf Snmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=L8e04InzHWwS2qV938Yr2jnku5auj+imiqdrP2lIFaA=; b=vPj2HZhrjw42ZJhttWgQ8ulEtTnzUYFbe4oZSUy2LOHbHwKMbqrOXuD2pi5jTASKgN GsB4gNqxn6dFR5Mf1hex1UTjQP2rz4A64Tx2BKWl/aD8mw5qhuyeTMsC2meIHcCLDWwd 7JfwIXlJwNr34Wi+1lswjNPhEyuk5Ph9Ky85SzUCHwt8UWjI8PnzWrREbH4SEHP92mDH cFgQFhsFXIoHl2KKCakj8UwAxOK+9N5bl75NoBV40n5GdeVC8VBdpcyl4Rdmaa8P9tq4 Qc+SfwDdo5OfZfGC1FpZOjYShseBKnIoxq7OrA0qDVcJAc+GbyKQh0HVoVeKD99AbrA4 gjVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h23si4362892ejb.269.2020.05.28.12.51.09; Thu, 28 May 2020 12:51:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728741AbgE1TqX (ORCPT + 99 others); Thu, 28 May 2020 15:46:23 -0400 Received: from mga17.intel.com ([192.55.52.151]:44023 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728688AbgE1TqE (ORCPT ); Thu, 28 May 2020 15:46:04 -0400 IronPort-SDR: I/1Hh/kElfz5zYvhuqua8Xb9QSgm7iiJZVU3rNhbtpNNunUoRJdOx9gHGp4VPi4GMbeXUWpqrR wfJQBw5Gvtxg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:46:04 -0700 IronPort-SDR: dRYAISkiX1NNkVtxVULMKqZt002txmSTrvWdtlwNu1ea2sbnNhNhJVXQqMbLtR4F+F6+K8f2bs 5NJN/hhXHqwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="256272198" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by orsmga007.jf.intel.com with ESMTP; 28 May 2020 12:46:04 -0700 Date: Thu, 28 May 2020 12:46:04 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+904752567107eefb728c@syzkaller.appspotmail.com Subject: Re: [PATCH] KVM: x86: Initialize tdp_level during vCPU creation Message-ID: <20200528194604.GE30353@linux.intel.com> References: <20200527085400.23759-1-sean.j.christopherson@intel.com> <40800163-2b28-9879-f21b-687f89070c91@redhat.com> <20200527162933.GE24461@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200527162933.GE24461@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 27, 2020 at 09:29:33AM -0700, Sean Christopherson wrote: > On Wed, May 27, 2020 at 06:17:57PM +0200, Paolo Bonzini wrote: > > On 27/05/20 10:54, Sean Christopherson wrote: > > > Initialize vcpu->arch.tdp_level during vCPU creation to avoid consuming > > > garbage if userspace calls KVM_RUN without first calling KVM_SET_CPUID. > > > > > > Fixes: e93fd3b3e89e9 ("KVM: x86/mmu: Capture TDP level when updating CPUID") > > > Reported-by: syzbot+904752567107eefb728c@syzkaller.appspotmail.com > > > Signed-off-by: Sean Christopherson > > > --- > > > 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 b226fb8abe41b..01a6304056197 100644 > > > --- a/arch/x86/kvm/x86.c > > > +++ b/arch/x86/kvm/x86.c > > > @@ -9414,6 +9414,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) > > > fx_init(vcpu); > > > > > > vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu); > > > + vcpu->arch.tdp_level = kvm_x86_ops.get_tdp_level(vcpu); > > > > > > vcpu->arch.pat = MSR_IA32_CR_PAT_DEFAULT; > > > > Queued, it is probably a good idea to add a selftests testcase for this > > (it's even okay if it doesn't use the whole selftests infrastructure and > > invokes KVM_CREATE_VM/KVM_CREATE_VCPU/KVM_RUN manually). > > Ya. syzbot is hitting a #GP due to NULL pointer during debugfs on the exact > same sequence. I haven't been able to reproduce that one (have yet to try > syzbot's exact config), but it's another example of a "dumb" test hitting > meaningful bugs. So we already have a selftest for this scenario, test_zero_memory_regions() in set_memory_region_test.c. Embarrassingly, I wrote the darn thing, I'm just really neglectful when it comes to running selftests. I'll looking into writing a script to run all selftests with a single command, unless someone already has one laying around?