Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp507077imm; Sat, 14 Jul 2018 05:59:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeqyDM1vIWf7aBVJf9aJpBQO6AZhnv9gR4nHFhpf/XiAfaK0YNVo90UIAUqgr5oBzwlWff9 X-Received: by 2002:a65:5907:: with SMTP id f7-v6mr9264465pgu.83.1531573149018; Sat, 14 Jul 2018 05:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531573148; cv=none; d=google.com; s=arc-20160816; b=lKclrpTSSiJSKnRcVMEnTStIVuFjWLDToQesLfxCumH7Ds1/myRZL9EvpZQqpHRWSC U1ADJbbV5R9gXn2hBnIA2hXoOGX85gs17dYG7nSgmMkPc0hEGswftl7b8aTIEHqPgZxP CO1hOXFNV55yARHVIpyfDP3TGGXbqF6JFrxrYD6Faj/cTqs5STPY28q/yaCcqjI4fz7n Kdkl+HilOFYD1dp677c4uexHMpptBb8yNfNfqy4iOlIzMjMHaBCOfreyHUScd6BFJcZx ZP6Ln3C/cVuZLIUmF+G4We1qFrHWYjCz2pkoni7BLNDwM5gxpkbAfSvfUH9qyN6Dj4tb k4jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=Q8ww/gmulwst9Ko3J7knSFdwJ+Gm9IFS4ghoFOP1U3I=; b=X0+BRhcwN4IQrs48leHT5VEk5s+y+jEepQcNXT3OmwWI1Oi/tOM0Of3uQ4Fd3N0d0j wmTFoQ9uFVNzpfUEyB+HalBFNXe+W289WMz4EFZufbYdFvHo1XmE9FNlLN+7gyxvKc10 9RSJcZ+sWtdOw0yMw3FA41d+x0HdIYUkMo2Aap5HEOrEzR5pBGpr4vn585SZ7n9YNPnK vwhYKALg11xhb2R+9kokljTf70qRfaIjVDM5Kx3hVaRwGy7hMuO+9Udw4skkI+NL8fH5 8FxwIdDVHFfROsMbmy7AY+3SbnjSoMA89bVVlmah9JKH0/4Gq6lJIeWmAPgQZK6fSu2W jIOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9-v6si26921385pfc.121.2018.07.14.05.58.53; Sat, 14 Jul 2018 05:59:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727402AbeGNNQy (ORCPT + 99 others); Sat, 14 Jul 2018 09:16:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46444 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbeGNNQx (ORCPT ); Sat, 14 Jul 2018 09:16:53 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9926DCFB; Sat, 14 Jul 2018 12:57:51 +0000 (UTC) Date: Sat, 14 Jul 2018 14:57:49 +0200 From: Greg Kroah-Hartman To: Dmitry Torokhov Cc: toddpoynor@gmail.com, rspringer@google.com, jnjoseph@google.com, benchan@chromium.org, frankhu@chromium.org, Simon Que , Guenter Roeck , devel@driverdev.osuosl.org, lkml , toddpoynor@google.com Subject: Re: [PATCH 06/18] staging: gasket: fix deadlock in pci driver unregister path Message-ID: <20180714125749.GA19498@kroah.com> References: <20180714055816.223754-1-toddpoynor@gmail.com> <20180714055816.223754-7-toddpoynor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 14, 2018 at 11:07:21AM +0300, Dmitry Torokhov wrote: > On Sat, Jul 14, 2018 at 8:58 AM Todd Poynor wrote: > > > > From: Todd Poynor > > > > g_mutex held across pci_unregister_driver() call, also held in > > gasket_pci_remove(), which deadlocks. > > > > Reported-by: Dmitry Torokhov > > Signed-off-by: Zhongze Hu > > Signed-off-by: Todd Poynor > > --- > > drivers/staging/gasket/gasket_core.c | 7 ++----- > > 1 file changed, 2 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c > > index 3bdf7d36b397..6d240dc59557 100644 > > --- a/drivers/staging/gasket/gasket_core.c > > +++ b/drivers/staging/gasket/gasket_core.c > > @@ -668,13 +668,10 @@ static void gasket_pci_remove(struct pci_dev *pci_dev) > > struct gasket_dev *gasket_dev = NULL; > > const struct gasket_driver_desc *driver_desc; > > /* Find the device desc. */ > > - mutex_lock(&g_mutex); > > + __must_hold(&g_mutex); > > And what exactly ensures that mutex is held here? Yes, we are holding > the mutex when we unload the driver, but PCI hot-unplug or unbinding > the device though sysfs do not go through module unload code path, so > you'll end up here without holding the mutex. Which is a huge reason the whole "wrap the pci core calls" is not going to work here at all. The device ownership rules are all wonky because of this. Unwinding that is key to getting all of this right. thanks, greg k-h