Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3202951ybh; Mon, 16 Mar 2020 18:08:30 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsxMhQozf1twoYGRU2dv8OsxhVYzAqb2pxCXUmbXxT5ZaeNHbn7uTViuRptYmm+FqSzz0cb X-Received: by 2002:aca:3386:: with SMTP id z128mr1541916oiz.40.1584407310744; Mon, 16 Mar 2020 18:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584407310; cv=none; d=google.com; s=arc-20160816; b=O61F1DQAoF6VOxgOPtCVfXOZ40ObEZSjTv6ZLUduyWSEKhJ1apyeCO8Qmq4ltY0SGK LhJWN3nxp08pEn2sUujfl+U8c56yBHUbPu344SkgvY2X6iGPiM4RPSJOz+Yu6Qh5DSao 2fpMZX+jIjlJDCFDWHAKCZ+DxDWf6IIW7TdwlgfELpHuiWgjXuILCipVX+Klv93YnjKu 6E0Fxc07fWDCXKQl+DgPGXVFXZnN0laDDAPj2k1pNtiH/nP5Oyc52jnIQ4rZEZ52vIRv M8LFxvmPE1Jyn6lKAhuSV1jToY6YYEL4uieztbtAYCASDuAsGgBWCJQ9WFF3baSP2PpB fw2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=cNXlJDXxz9gnIiGdzwArHrJUwLPJIKrNHOosUtI8l4A=; b=SnotpzrFoMffvH2wEBo+9xierupbcRXz6ElN6aOfGTpgs11PvQcen5ppJQ+7c908Ol sHmypX6krk6u0ETaGuHnDXIl1HED4kz4AqduYX1XkNl9UWt4Wz7F91SJ6NrGnLPxKoqP IJ1OnVnuFN8NTBHsi7KR7PeJywe3FJm29BInsTeS5EqTLYP0Un5ub4Y9iCRUzdWAj2BK Q3ms0qxHWzFnX//ZiZUNacPkhz5RgDiA4ioESSAaxVcYY/nAuaSiuz2sa4AL837sQD6d eeFpKh5oqO+Idk2vpddrjelwlLyIcCEexRRFGcgjZP+SfF0cHBEHADEvA45YdyViNtGM h9iw== 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 23si834433ois.29.2020.03.16.18.08.19; Mon, 16 Mar 2020 18:08:30 -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 S1733257AbgCQA4O (ORCPT + 99 others); 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