From patchwork Wed Dec 13 01:56:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Levin, Alexander" X-Patchwork-Id: 10108605 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 60AFC602CA for ; Wed, 13 Dec 2017 01:57:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52074289B9 for ; Wed, 13 Dec 2017 01:57:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46AD328A70; Wed, 13 Dec 2017 01:57:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C202289B9 for ; Wed, 13 Dec 2017 01:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752811AbdLMB5H (ORCPT ); Tue, 12 Dec 2017 20:57:07 -0500 Received: from fldsmtpe03.verizon.com ([140.108.26.142]:57985 "EHLO fldsmtpe03.verizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752348AbdLMB46 (ORCPT ); Tue, 12 Dec 2017 20:56:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1513130218; x=1544666218; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=gcJkmSLkpJWIledJ3H06s/Ml1qIrnpOpH7lXNg7wdWE=; b=XGVqW+xscL2N+vKGdkx2HFvjLgBfoJ4QWPVRdFy65oczEgwnlrB4uuwC U9ihj04i7hURPqter8TiWhK/1B9F5DIk/SewRg2WnriJlF3DN1gq4aNpy kdtM+JMgNg9yP0n5wziAq59YFLIC+Op6Xq7RjDVxC3hvDFdN9MF8zAnxA s=; Received: from unknown (HELO fldsmtpi02.verizon.com) ([166.68.71.144]) by fldsmtpe03.verizon.com with ESMTP; 13 Dec 2017 01:56:53 +0000 Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO apollo.verizonwireless.com) ([10.255.192.101]) by fldsmtpi02.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Dec 2017 01:56:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1513130212; x=1544666212; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=gcJkmSLkpJWIledJ3H06s/Ml1qIrnpOpH7lXNg7wdWE=; b=gCCIxbrfVXMbIyZp7cWJBglF9bYPVF0L1D9SRVVk+xNa4xaSJ/Gqv7/T k0AJHKekBbV3qIl/JBF/Ob2oECzBm45+D34AiakQfd0IiCRJBJYLOH+8a skMu9CSTMFxsKrvuMLr0RBo6p29NQj21S1wDbephW3mTUM3Sk4F/pVkUn g=; Received: from pioneer.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.34]) by apollo.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Dec 2017 20:56:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1513130212; x=1544666212; h=to:subject:date:message-id:references:in-reply-to: content-id:content-transfer-encoding:mime-version:from:cc; bh=gcJkmSLkpJWIledJ3H06s/Ml1qIrnpOpH7lXNg7wdWE=; b=olh5HSB2Mx+qx2kXew+zqcfjGW6NTFBtfZwIbIwalprLd9GPnPaTUrFH Z4puQ3os8hgMPK6WMAxzcYUeE+y9VMQB+0NHNhJEhQ63FgHmWSRfnUFcm O6LCfAJhfseZv6F41awNOV3ICNQxT85ZdUaL6+tD5/vg/MdJ2AbFH1Un3 M=; From: alexander.levin@verizon.com Cc: Dmitry Vyukov , Joerg Roedel , "Paolo Bonzini" , =?utf-8?B?UmFkaW0gS3LEjW3DocWZ?= , David Hildenbrand , "kvm@vger.kernel.org" , "syzkaller@googlegroups.com" , alexander.levin@verizon.com X-Host: pioneer.tdc.vzwcorp.com Received: from ohtwi1exh003.uswin.ad.vzwcorp.com ([10.144.218.45]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 13 Dec 2017 01:56:52 +0000 Received: from tbwexch19apd.uswin.ad.vzwcorp.com (153.114.162.43) by OHTWI1EXH003.uswin.ad.vzwcorp.com (10.144.218.45) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 12 Dec 2017 20:56:52 -0500 Received: from OMZP1LUMXCA16.uswin.ad.vzwcorp.com (144.8.22.194) by tbwexch19apd.uswin.ad.vzwcorp.com (153.114.162.43) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Tue, 12 Dec 2017 20:56:51 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA16.uswin.ad.vzwcorp.com (144.8.22.194) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Tue, 12 Dec 2017 19:56:50 -0600 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Tue, 12 Dec 2017 19:56:50 -0600 To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH AUTOSEL for 4.9 004/100] kvm: fix usage of uninit spinlock in avic_vm_destroy() Thread-Topic: [PATCH AUTOSEL for 4.9 004/100] kvm: fix usage of uninit spinlock in avic_vm_destroy() Thread-Index: AQHTc7WOuAcjIFI38UGWIs5rSNse2A== Date: Wed, 13 Dec 2017 01:56:14 +0000 Message-ID: <20171213015606.6568-4-alexander.levin@verizon.com> References: <20171213015606.6568-1-alexander.levin@verizon.com> In-Reply-To: <20171213015606.6568-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] Content-ID: <553185A4ECD10A48BF459508AD1999A0@vzwcorp.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dmitry Vyukov [ Upstream commit 3863dff0c3dd72984395c93b12383b393c5c3989 ] 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 Reviewed-by: David Hildenbrand Signed-off-by: Radim Krčmář Signed-off-by: Sasha Levin --- arch/x86/kvm/svm.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.11.0 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 23f1a6bd7a0d..8148d8ca7930 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)