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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no 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 7D6F4C2BB1D for ; Tue, 17 Mar 2020 00:56:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 60B4520679 for ; Tue, 17 Mar 2020 00:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733261AbgCQA4O (ORCPT ); Mon, 16 Mar 2020 20:56:14 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:53161 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733119AbgCQA4O (ORCPT ); Mon, 16 Mar 2020 20:56:14 -0400 Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jE0Wg-0007YB-AC; Tue, 17 Mar 2020 01:56:10 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id BA8A0101161; Tue, 17 Mar 2020 01:56:09 +0100 (CET) From: Thomas Gleixner To: Logan Gunthorpe , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Sebastian Andrzej Siewior , Logan Gunthorpe Subject: Re: [PATCH] PCI/switchtec: Fix init_completion race condition with poll_wait() In-Reply-To: <20200313183608.2646-1-logang@deltatee.com> References: <20200313183608.2646-1-logang@deltatee.com> Date: Tue, 17 Mar 2020 01:56:09 +0100 Message-ID: <87mu8fdck6.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > To my knowledge, no one has hit this bug, but we should fix it for > correctness. s/,but we should fix/.Fix/ ? > 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 @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? Thanks, tglx