Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3245962ybh; Mon, 16 Mar 2020 19:06:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs8gaa+nBhIVU0dQSloMpuy4lHRbiM6+ocHqsEeSjfez8wfYWBl1zE0vLf8htS7+f1xnsvE X-Received: by 2002:aca:190f:: with SMTP id l15mr1795723oii.48.1584410768156; Mon, 16 Mar 2020 19:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584410768; cv=none; d=google.com; s=arc-20160816; b=wcoiWeamSL7exdbQA2ipqOU5D9wFroK0r0yDG4IiQRZXq9nGreuRltfw/dNDpPMRyA MbzLaplKzPtzAngi4oBTkGUi/YJUBnIb88SvGVCwc4tsxkj4zV9lsCkGVkHNkA09YhI1 90DCEnsfpKrqM2Bh+6x33g6IFe5xLljk9wSweJGYjvbF4aPo2ALUq/jTgqqq0ayCcbll wZK7g+yvF/JMUx1nI9LSrYyth+/PgDf8c5J7gY65dAG8YdJ9rFPiy16SI1bVBdpcFhmu Ex5C8M+zfxH+uodCdlupWsTEu1/vYJyeDo39M9pk7oyFzCqIVuz2TKyTYZf/9fd4xaT9 b3rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=bm/myb4/LuuUoOq/9aKxHM/xV4BsWbOEVJCx7xz2T5w=; b=Wa+8q+QafYS9SnCWlm/21J8xZb0aE3fXVoIBAkRZd44WOKmnqeYtbot7iYVttJMg7L ROtI95vqqkhy92d4uIqSA2oIi4rIXXZivWSmPYFs9AdOGomX8e9UwuD6hEmujy/HlPq+ 4WnEcupnWXDMxle6OTSGCfISk7z2E9LMEyaQhr20ORJSvDDCftbosL3R580CBdlWtyTH vb7p8y8zNTSQD1/cOQdJtHt6WLfsoy6zBZ0osbr4ATqhaLvpjCNppWwERmLzlwn0n1Tp fRVyv65i/tgumjRcvsvXLOgcWJs6zobbfq+kk/t6MJ2WxVgRl/8+X259DV6gaPRGSNMY TTfw== 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 v22si911807oic.271.2020.03.16.19.05.56; Mon, 16 Mar 2020 19:06: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 S1733192AbgCQBZR (ORCPT + 99 others); Mon, 16 Mar 2020 21:25:17 -0400 Received: from ale.deltatee.com ([207.54.116.67]:55060 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733017AbgCQBZQ (ORCPT ); Mon, 16 Mar 2020 21:25:16 -0400 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1jE0yo-0008I8-Hx; Mon, 16 Mar 2020 19:25:15 -0600 To: Thomas Gleixner , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Sebastian Andrzej Siewior References: <20200313183608.2646-1-logang@deltatee.com> <87mu8fdck6.fsf@nanos.tec.linutronix.de> From: Logan Gunthorpe Message-ID: <38781f88-32df-e89a-7d00-fd2fcc097497@deltatee.com> Date: Mon, 16 Mar 2020 19:25:14 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <87mu8fdck6.fsf@nanos.tec.linutronix.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: bigeasy@linutronix.de, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,SURBL_BLOCKED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH] PCI/switchtec: Fix init_completion race condition with poll_wait() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-03-16 6:56 p.m., Thomas Gleixner wrote: > Logan, > > Logan Gunthorpe writes: > >> 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) > > just a nitpick. As you took the liberty to copy the description of the > race, which was btw. disovered by me, verbatim from a changelog written > by someone else w/o providing the courtesy of linking to that original > analysis, allow me the liberty to add the missing link: > > Link: https://lore.kernel.org/lkml/20200313174701.148376-4-bigeasy@linutronix.de Well, I just copied the call chain. I had no way to know you were the one who discovered the bug given the way it was presented to me. And the original patch didn't include much in the way of analysis of the bug, just "It's Racy". I didn't deliberately omit the link, it just never occurred to me to add it. In retrospect, I should have included it, sorry about that. >> To my knowledge, no one has hit this bug, but we should fix it for >> correctness. > > s/,but we should fix/.Fix/ ? Yes, that's an improvement. >> 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 > > Acked-by: Thomas Gleixner Thanks. > @Bjorn: Can you please hold off on this for a few days until we sorted > out the remaining issues to avoid potential merge conflicts > vs. the completion series? I'd suggest simply rebasing the completion patch on this patch, or a patch like it. Then we'll have the proper bug fix commit and there won't be a conflict. Logan