From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] kvm: fix usage of uninit spinlock in avic_vm_destroy() Date: Tue, 14 Mar 2017 21:38:00 +0100 Message-ID: <20170314203800.GB14790@potion> References: <20170124130648.75935-1-dvyukov@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: pbonzini@redhat.com, Joerg Roedel , David Hildenbrand , kvm@vger.kernel.org, syzkaller@googlegroups.com To: Dmitry Vyukov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:38882 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751152AbdCNUiG (ORCPT ); Tue, 14 Mar 2017 16:38:06 -0400 Content-Disposition: inline In-Reply-To: <20170124130648.75935-1-dvyukov@google.com> Sender: kvm-owner@vger.kernel.org List-ID: 2017-01-24 14:06+0100, Dmitry Vyukov: > If avic is not enabled, avic_vm_init() does nothing and returns early. > However, avic_vm_destroy() still tries to destroy what hasn't been created. > The only bad consequence of this now is that avic_vm_destroy() uses > svm_vm_data_hash_lock that hasn't been initialized (and is not meant > to be used at all if avic is not enabled). > > Return early from avic_vm_destroy() if avic is not enabled. > It has nothing to destroy. > > Signed-off-by: Dmitry Vyukov > Cc: Joerg Roedel > Cc: Paolo Bonzini > Cc: "Radim Krčmář" > Cc: David Hildenbrand > Cc: kvm@vger.kernel.org > Cc: syzkaller@googlegroups.com > --- svm_vm_data_hash_lock is initialized unconditionally now, so I've queued it for 4.12, Thanks. > arch/x86/kvm/svm.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 08a4d3ab3455..3aecaa13fd22 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -1382,6 +1382,9 @@ static void avic_vm_destroy(struct kvm *kvm) > unsigned long flags; > struct kvm_arch *vm_data = &kvm->arch; > > + if (!avic) > + return; > + > avic_free_vm_id(vm_data->avic_vm_id); > > if (vm_data->avic_logical_id_table_page) > -- > 2.11.0.483.g087da7b7c-goog >