From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FAKE_REPLY_C,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6714C4332E for ; Wed, 18 Mar 2020 21:25:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7CACC208D5 for ; Wed, 18 Mar 2020 21:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584566721; bh=PPihHaGg1zzpn1nHu5VlZHYT+H8Lm/yb44OJhzptGDI=; h=Date:From:To:Cc:Subject:In-Reply-To:List-ID:From; b=elZaxJhQFCGRxjkYrm3lROT5QlG16gujUTD4EHsgK0saK8pfTKt99q+taMYVKGD7w Md+bR1bu8nem/1nkmR8d8V7X5IkKrYGiAIynJC14FEq7scmaH8jk9pUjW+Ppz0X5i5 A4BgflmzIzqOsP1Xgf8Kgmkmx+tyX6Sodou2SJ2g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726827AbgCRVZR (ORCPT ); Wed, 18 Mar 2020 17:25:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:53380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbgCRVZQ (ORCPT ); Wed, 18 Mar 2020 17:25:16 -0400 Received: from localhost (mobile-166-175-186-165.mycingular.net [166.175.186.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A267920772; Wed, 18 Mar 2020 21:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584566716; bh=PPihHaGg1zzpn1nHu5VlZHYT+H8Lm/yb44OJhzptGDI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=J4R5BuBT7s0ufQ6OkQFm2DJaGU3GVO9cGs2MX4LtzTi7i9JWE5dM20xu5JQTXlZ83 PEvcq3DTg4VilmyOANCyGwCHYadT4otbhpLYSpa8TZJkQXYvR3a8J+LlUM3ulELzZx jLKhC0M9bULug4AxIw26CRfmCEZy/H4Ad8J0WRnI= Date: Wed, 18 Mar 2020 16:25:13 -0500 From: Bjorn Helgaas To: Thomas Gleixner Cc: LKML , Peter Zijlstra , Linus Torvalds , Ingo Molnar , Will Deacon , "Paul E . McKenney" , Joel Fernandes , Steven Rostedt , Randy Dunlap , Sebastian Andrzej Siewior , Logan Gunthorpe , Kurt Schwemmer , linux-pci@vger.kernel.org, Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Kalle Valo , "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Oleg Nesterov , Davidlohr Bueso , Michael Ellerman , Arnd Bergmann , linuxppc-dev@lists.ozlabs.org Subject: Re: [patch V2 01/15] PCI/switchtec: Fix init_completion race condition with poll_wait() Message-ID: <20200318212513.GA240916@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200318204407.497942274@linutronix.de> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Wed, Mar 18, 2020 at 09:43:03PM +0100, Thomas Gleixner wrote: > From: Logan Gunthorpe > > The call to init_completion() in mrpc_queue_cmd() can theoretically > race with the call to poll_wait() in switchtec_dev_poll(). > > poll() write() > switchtec_dev_poll() switchtec_dev_write() > poll_wait(&s->comp.wait); mrpc_queue_cmd() > init_completion(&s->comp) > init_waitqueue_head(&s->comp.wait) > > To my knowledge, no one has hit this bug. > > Fix this by using reinit_completion() instead of init_completion() in > mrpc_queue_cmd(). > > Fixes: 080b47def5e5 ("MicroSemi Switchtec management interface driver") > Reported-by: Sebastian Andrzej Siewior > Signed-off-by: Logan Gunthorpe > Signed-off-by: Thomas Gleixner > Link: https://lkml.kernel.org/r/20200313183608.2646-1-logang@deltatee.com Acked-by: Bjorn Helgaas Not because I understand and have reviewed this, but because I trust you to do the right thing and it belongs with the rest of the series. > --- > drivers/pci/switch/switchtec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c > index a823b4b8ef8a..81dc7ac01381 100644 > --- a/drivers/pci/switch/switchtec.c > +++ b/drivers/pci/switch/switchtec.c > @@ -175,7 +175,7 @@ static int mrpc_queue_cmd(struct switchtec_user *stuser) > kref_get(&stuser->kref); > stuser->read_len = sizeof(stuser->data); > stuser_set_state(stuser, MRPC_QUEUED); > - init_completion(&stuser->comp); > + reinit_completion(&stuser->comp); > list_add_tail(&stuser->list, &stdev->mrpc_queue); > > mrpc_cmd_submit(stdev); > -- > 2.20.1 > >