Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp901049pxu; Thu, 3 Dec 2020 15:55:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcuobGpEGkcb1aqixz5Mrh8xB/2KVDFMg1aoG1wMkdrvg4BDfxvuUrnUmDHb8gfHJfOCvd X-Received: by 2002:a17:906:82ce:: with SMTP id a14mr4776024ejy.421.1607039717514; Thu, 03 Dec 2020 15:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607039717; cv=none; d=google.com; s=arc-20160816; b=O7l5SbVuEe1LPbZ/CfVmiFsq4aIFOWmkGsQo0tiKq+4wsJAJi2fN5janNVlInv887s FqylAgQZWtddyrlZm7vfDSkpu/QQ086fJVSZtiEUL+FyI6gV76W9bDg75P1l0sXD0G9+ +Ol2UI1+0v7yLdpHEvxZ1idlY6jiiETh8C2r0cXCmkkDKGePFDMRBkmRs2vdBpa2THcb S00NKG3JxB/NwRiOzaxG68BMngtM6ojVslFbnmRXucVesW9CfJr6TPC9N4hkc1qdNh2H T7YYGkqPvWUYC/Wc4yBeN6WjstXp4QuAQzwGPIenIwS6lvt+Er8FacrEs0F3qQg+QDKR WKEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=YYMeh+MuWwsdI9rSYUGVMvNUpGwpQQJeqKMCOCtMEZk=; b=XnH7Uz4FMZj33HmQO/i2IUbWMHuTAwRILjxbc33JL9P+3BsPGCpXU8tCBU7uqRxNXX +Ad7ZIMu4P2SL1jNCp6hi6eCPBeCyZF1mWl2BRfF/+FKU+r6JESNYnNZIe4xz9UKnP/T KlxUsFdrBni5jQOl4SaIILMBdTbkZRVrkqKiRti4n3ocn3E3JtCR/r+hdi+CLPSx4xCx vHLdUH9GFGVI44yubvm51EJYCXWAUeBR+bBX3P764H6p964Z+N4vi3T3+G+2NJvBsHKy QLlydujuEWoAPnOKQcjAX+hIQOKz06qsZKSxLdPkzFht4NbWzOjoWLjwsYmng2I81bYM ZrEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VQcspdcQ; 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 u18si1875189edy.420.2020.12.03.15.54.55; Thu, 03 Dec 2020 15:55:17 -0800 (PST) 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=VQcspdcQ; 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 S1728199AbgLCXvS (ORCPT + 99 others); Thu, 3 Dec 2020 18:51:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36843 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726924AbgLCXvR (ORCPT ); Thu, 3 Dec 2020 18:51:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607039391; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YYMeh+MuWwsdI9rSYUGVMvNUpGwpQQJeqKMCOCtMEZk=; b=VQcspdcQC/w4bfdQpvHZokBj9Z9f18VejMpL5UGFJdZ4JKCcgjypobBxcHbh6lkfLPKqJb SOlPQLskTdtt+raODj5SmjRlW6GIlEJISEvdpm9XSocIiGPKU9dViVzy8g0/jP+JVH1Qmi 0B9d1GrcAxs8hpPvqXjyk3tx5xocG70= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-2FvD_kYzPku0JPEUnj37ow-1; Thu, 03 Dec 2020 18:49:48 -0500 X-MC-Unique: 2FvD_kYzPku0JPEUnj37ow-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D7EA10054FF; Thu, 3 Dec 2020 23:49:47 +0000 (UTC) Received: from w520.home (ovpn-112-10.phx2.redhat.com [10.3.112.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1A565C1CF; Thu, 3 Dec 2020 23:49:43 +0000 (UTC) Date: Thu, 3 Dec 2020 16:49:43 -0700 From: Alex Williamson To: Eric Auger Cc: eric.auger.pro@gmail.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, cohuck@redhat.com, xyjxie@linux.vnet.ibm.com Subject: Re: [PATCH] vfio/pci: Move dummy_resources_list init in vfio_pci_probe() Message-ID: <20201203164943.3b78c35d@w520.home> In-Reply-To: <20201113175202.4500-1-eric.auger@redhat.com> References: <20201113175202.4500-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Nov 2020 18:52:02 +0100 Eric Auger wrote: > In case an error occurs in vfio_pci_enable() before the call to > vfio_pci_probe_mmaps(), vfio_pci_disable() will try to iterate > on an uninitialized list and cause a kernel panic. > > Lets move to the initialization to vfio_pci_probe() to fix the > issue. > > Signed-off-by: Eric Auger > Fixes: 05f0c03fbac1 ("vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive") > CC: Stable # v4.7+ > --- > drivers/vfio/pci/vfio_pci.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) Thanks, Eric. Applied to vfio next branch for v5.11. Alex > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > index e6190173482c..47ebc5c49ca4 100644 > --- a/drivers/vfio/pci/vfio_pci.c > +++ b/drivers/vfio/pci/vfio_pci.c > @@ -161,8 +161,6 @@ static void vfio_pci_probe_mmaps(struct vfio_pci_device *vdev) > int i; > struct vfio_pci_dummy_resource *dummy_res; > > - INIT_LIST_HEAD(&vdev->dummy_resources_list); > - > for (i = 0; i < PCI_STD_NUM_BARS; i++) { > int bar = i + PCI_STD_RESOURCES; > > @@ -1966,6 +1964,7 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) > mutex_init(&vdev->igate); > spin_lock_init(&vdev->irqlock); > mutex_init(&vdev->ioeventfds_lock); > + INIT_LIST_HEAD(&vdev->dummy_resources_list); > INIT_LIST_HEAD(&vdev->ioeventfds_list); > mutex_init(&vdev->vma_lock); > INIT_LIST_HEAD(&vdev->vma_list);