Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2110262pxk; Mon, 14 Sep 2020 05:13:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGSLrIwCfSDTGvfxD5XCkVBgob0+NHR+rP86Cu9pq1oV6APfSr/LOT+kENinGsDepT2Jeo X-Received: by 2002:a17:906:a444:: with SMTP id cb4mr14092747ejb.432.1600085610707; Mon, 14 Sep 2020 05:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600085610; cv=none; d=google.com; s=arc-20160816; b=u4/NHYk0nMrXSmIVwAJetyzc3djiyFAFcPPC9rEnm6JgEHs205A4ofAFrwAO4egwht Zn0YDAnV3cixcB/eKdGNeetHK3529fdhCVT6IoLm+55T7D392oCyc/fnNr+GacLKX6xV F18GpwRLH4/GtmPwmJaRa08WpGYgHlBnnJMZlyxs739gdakCJ6QwhmErBVdBK37PfuIV vpKmr1jOL8lWV1tQmCxBuK4jBWgIZ06eQrDIVQ7ALytWkeOCxiqkkivfbSgwavYyUJN/ fpICYi6uys2JdXZby0OCIZy8cK/RExh2l9lZP2ZydhgVpnIk8xjOoqwwXI1l2COAaz3F I+Qg== 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 :message-id:date:subject:cc:to:from; bh=QgRlCflCno7CElBe1nW2ShoQ1T9kOgyWL3BgOKjYiJo=; b=cVS2qADIX8Y+R9d2sFtdIfePh83UUHqyBCz06h/1WLGnCRmVTrrG6BdSpfmP9TTApx jXCj9DjaNTWT8kwkdNDOnyefn0aXmcGvY7t0NNNUG3TMyKqxGTf3iTrounpSDQzx2iVP ALgKAy+/B59sYGeOSKNpUCrRhtqF3owg+XYMQLbDmsPqHLMGcoGRRirT+PkmruKniLYy vdUt4XMlfFBFxutjOcsEr8B7JjxsA8wIVDfqY1QPnV0cjvACv+1V9JVjlFFklEs4kV/i dYhCKPHs0s8ozOSbCiKeDMhMs1jNQTC2d47MRuoiTpL7q8mrpZp5J6f/PoJ4sBFQC1aj 5pcg== 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=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si6953400edv.103.2020.09.14.05.13.08; Mon, 14 Sep 2020 05:13:30 -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=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725944AbgINMLZ (ORCPT + 99 others); Mon, 14 Sep 2020 08:11:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbgINMEE (ORCPT ); Mon, 14 Sep 2020 08:04:04 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E34EC061788; Mon, 14 Sep 2020 04:53:35 -0700 (PDT) Received: from cap.home.8bytes.org (p549add56.dip0.t-ipconnect.de [84.154.221.86]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id 4F1801DB; Mon, 14 Sep 2020 13:51:30 +0200 (CEST) From: Joerg Roedel To: Borislav Petkov , Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel , Dan Carpenter Subject: [PATCH -tip] KVM: SVM: nested: Initialize on-stack pointers in svm_set_nested_state() Date: Mon, 14 Sep 2020 13:51:29 +0200 Message-Id: <20200914115129.10352-1-joro@8bytes.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel The save and ctl pointers need to be initialized to NULL because there is a way through the function in which there is no memory allocated for the pointers but where they are freed in the end. This involves the 'goto out_set_gif' before the memory for the pointers is allocated. Reported-by: Dan Carpenter Fixes: 6ccbd29ade0d ("KVM: SVM: nested: Don't allocate VMCB structures on stack") Signed-off-by: Joerg Roedel --- arch/x86/kvm/svm/nested.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 598a769f1961..72a3d6f87107 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1062,8 +1062,8 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu, struct vmcb *hsave = svm->nested.hsave; struct vmcb __user *user_vmcb = (struct vmcb __user *) &user_kvm_nested_state->data.svm[0]; - struct vmcb_control_area *ctl; - struct vmcb_save_area *save; + struct vmcb_control_area *ctl = NULL; + struct vmcb_save_area *save = NULL; int ret; u32 cr0; -- 2.28.0