Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2346057pxk; Mon, 14 Sep 2020 10:49:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI9jjA5wAudnBXrqVb/aUX3HUXCtzu4rpymIbCBqTAbCaK2G+NK9ywRS388NHmCr2yIVii X-Received: by 2002:a17:906:c411:: with SMTP id u17mr15560704ejz.319.1600105776235; Mon, 14 Sep 2020 10:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600105776; cv=none; d=google.com; s=arc-20160816; b=AxsOeVqywEpcjBDJce4xDqpPZsbDG8K7DK/U/0FWsRvqY93wEu2zuiJn9keXAY1APb CfwBZ8fwUY7DuyofzconmIGzt8FL7n7oNJPvAzJ8F+B1yyjFz1tchg+o7uKsxifjYJxi ed+E3XqFZD0w34LW2Uw4Kt6RpoiSQy8L6uF+CPfP+DYTmQlIkX3O2n3OLx7sPdLzhL/a mnq+MhznR1sldmNxsFkj8KNW6zYc+zNlupKrBbZl9Ghg+dIDhI0ekUa1j8qcrD7v0io3 rZNU5gDah/sqiI0BtWYuwjudAAQh2WkgZlx45vCf9gh3BJJNlEh77daSRzIFkzMxfuLi Rn1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=k2l6ayUzFIexzXgZyZrDYGU+vmfRTf0Myc4Tfjg1GY4=; b=k1jNmDQPynyn/bJAe7DyctVj2BEb/BM3JTz+8E2mQ4Lzi5jkMeDK/qqlNFJ2DHG1+b /w7K9Q14CELaCDOh/axFGZK3xrQeJ+o20u2gpu25o1+P1n+bdQr7+JTFkyt9vDLustp2 bWTdDfewsVWG3Xc8o4JjY3l4POlO7oF2CHVmbFjhlCaRSm/dMqHQqHlDIJLvo1iCEI6N +hjMrJ0RZi0a6V7iNjW8RhretiidnT0Vn22yhMDZ+cKm39DmFoW6OiBJEGGZ4Td0UUB8 C7duiQA8qHAdU5kKWvW/rB5epCDdSUD1VG4Glk61rN9ntGX1Wzhr0MzBjcVK4hcn4hi6 qO6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fUdOTABW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si8024952edt.233.2020.09.14.10.49.14; Mon, 14 Sep 2020 10:49:36 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fUdOTABW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726202AbgINRpy (ORCPT + 99 others); Mon, 14 Sep 2020 13:45:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59323 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbgINMFU (ORCPT ); Mon, 14 Sep 2020 08:05:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600085072; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=k2l6ayUzFIexzXgZyZrDYGU+vmfRTf0Myc4Tfjg1GY4=; b=fUdOTABWMh/el1+YKHgoN7utDNTNoHQ7LTie0XKNhhOHtjLET52eX2jLWKNloIUwbjrS9j D5QFOpZT4lN/2HQA4ql+8ykoR4laXbx0vvmVu8GaHkl85vEaEBkjzzCj1ed3dypelbFN7L u2Huox+qkwtm3lO+X1mkNYQHS6nAJvI= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-294-wFFiz2Q8OqqnNEKIxnjlPw-1; Mon, 14 Sep 2020 08:04:30 -0400 X-MC-Unique: wFFiz2Q8OqqnNEKIxnjlPw-1 Received: by mail-wm1-f69.google.com with SMTP id b20so1020779wmj.1 for ; Mon, 14 Sep 2020 05:04:30 -0700 (PDT) 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:in-reply-to:references:date :message-id:mime-version; bh=k2l6ayUzFIexzXgZyZrDYGU+vmfRTf0Myc4Tfjg1GY4=; b=CRnznKRv051bMNA9BkLqSVUcKKZ/7NI3nJbZQWJIHHzLowLai6Xya1XIP3Vkayi9ir EVT7pR5FLRESjn60MO0JOcUrYpiNGBjBtwpXeyKDbsr0r673JWCg9p9YBVcHBXOaNX0z 1mXN5+fbqyHzrNvgWcU/laOF7Bs2bn05Y6NVV3vTpZx58B7nXgBWuMVIyTxwR52/6xxG 9AsBw4aACVk4cSwS00P/YK0rGbzlSpuSoGMprz0XMjCLryvINp3q8zCf4Rtn7ObLxJcd 4iR8EfAXuXTAnnoYznNusPXG2Q9jbq8aa6FsoCvVjd0foPmA3ZQwYj8IXVJncE8DEi1g QC9g== X-Gm-Message-State: AOAM5321XKuwEGemLu5sb5bqZRVXNJKoLOwVexW9kYTcrDbohLZsfUvX 9MtgjUO84/2PNzPX0dLHriz0n3/wnpskwcGcTiIh4Uv9S5sjxHBhslVgk4LtbmEp1YrwyQmL2hc KjtsW5bzjucMana02wEWQi9dp X-Received: by 2002:a5d:46cf:: with SMTP id g15mr15751970wrs.107.1600085069697; Mon, 14 Sep 2020 05:04:29 -0700 (PDT) X-Received: by 2002:a5d:46cf:: with SMTP id g15mr15751952wrs.107.1600085069498; Mon, 14 Sep 2020 05:04:29 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id 8sm20940521wrl.7.2020.09.14.05.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 05:04:28 -0700 (PDT) From: Vitaly Kuznetsov To: Joerg Roedel Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel , Dan Carpenter , Borislav Petkov , Paolo Bonzini , Colin King Subject: Re: [PATCH -tip] KVM: SVM: nested: Initialize on-stack pointers in svm_set_nested_state() In-Reply-To: <20200914115129.10352-1-joro@8bytes.org> References: <20200914115129.10352-1-joro@8bytes.org> Date: Mon, 14 Sep 2020 14:04:27 +0200 Message-ID: <87ft7klg38.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Joerg Roedel writes: > 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; Hi Joerg, this was previously reported by Colin: https://lore.kernel.org/kvm/20200911110730.24238-1-colin.king@canonical.com/ the fix itself looks good, however, I had an alternative suggestion on how to fix this: https://lore.kernel.org/kvm/87o8mclei1.fsf@vitty.brq.redhat.com/ -- Vitaly