Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1932759ybb; Sat, 21 Mar 2020 08:55:28 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt0M5lfGCirAGBrco1GrW6bzVO2V81YhTUas4zi9lKFVltMSpHd0zc6larrSvfZLrnqkQ71 X-Received: by 2002:aca:d68a:: with SMTP id n132mr11418392oig.40.1584806128136; Sat, 21 Mar 2020 08:55:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584806128; cv=none; d=google.com; s=arc-20160816; b=lEYoj3GMJ8hlsbE9GhZ7UpoCaq3dwSNeLwBvckX9sQp8v3cCFK2V/DtB2f3JJzc+RH 0yqPCQ9sRRmnFquqy8/kNGG9OD8AmYZlDlHc4iTH3d7kbmvjJPZxWHRubn7QgbxtdS2Z ZhH3GziU+FlnrCERD3NsfrzfdcZk4hK/eNp6qOklM1oQzGsJJ+gCX2cMWZfrG2OnSAyV 22lbDjAJFCaSSZ+OEh4BQmQ7FqYUiKEK/oYHZEgVXXwpZfSPwGCWxykAgqVFQux53jfi I0M57qPvs43DSVNCTrGuyzB4XnIOmn+1caGb65NC5OH3bcLBEAFWBegtB3ymOS16DQav 8ciQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=BDHB3mo+tIQQ7YQ1dgp3gjoyBC2XyKz9wkQmDppTkyM=; b=f91Ok3cPevECgBNZ4WIKp/2Y1Kr4O8pvmK4J+4+dzl93kzxInH4O1NnPxeYjj99QDC xL3N5X19wSb5DWK/1JDecR9TGqziMZ4cYq42C4SIgHCv+CQCwojKXQSs++SBgA9v4WCr GezZZ/K8v+MZTv/W+GXU1b6GTc/OPKq44jGRJn8+Dw8zjGPbM0AuvNUV+zoatSpxYIxJ myBc9xBH1CmCYBGO9wue2+68aWXqP2ENymD6IrlYvJcM/Tx7bMlHcrTdjw0nf7wZEsi1 V97AMoXgoVUBZHZ1m7cLTe0h3Z7momB0rgACUPvtihettl9LdZRUNXfCFqOcNkEI/Da4 toCw== 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 l129si4945836oif.15.2020.03.21.08.55.16; Sat, 21 Mar 2020 08:55:28 -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 S1728129AbgCUPyh (ORCPT + 99 others); Sat, 21 Mar 2020 11:54:37 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:39078 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727891AbgCUPyD (ORCPT ); Sat, 21 Mar 2020 11:54:03 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jFgRi-0005Wq-61; Sat, 21 Mar 2020 16:53:58 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 791541C22F0; Sat, 21 Mar 2020 16:53:53 +0100 (CET) Date: Sat, 21 Mar 2020 15:53:53 -0000 From: "tip-bot2 for Logan Gunthorpe" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] PCI/switchtec: Fix init_completion race condition with poll_wait() Cc: Sebastian Andrzej Siewior , Logan Gunthorpe , Thomas Gleixner , "Peter Zijlstra (Intel)" , Bjorn Helgaas , x86 , LKML In-Reply-To: <20200313183608.2646-1-logang@deltatee.com> References: <20200313183608.2646-1-logang@deltatee.com> MIME-Version: 1.0 Message-ID: <158480603317.28353.1853956587316616991.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 The following commit has been merged into the locking/core branch of tip: Commit-ID: efbdc769601f4d50018bf7ca50fc9f7c67392ece Gitweb: https://git.kernel.org/tip/efbdc769601f4d50018bf7ca50fc9f7c67392ece Author: Logan Gunthorpe AuthorDate: Sat, 21 Mar 2020 12:25:45 +01:00 Committer: Peter Zijlstra CommitterDate: Sat, 21 Mar 2020 16:00:20 +01:00 PCI/switchtec: Fix init_completion race condition with poll_wait() 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 Signed-off-by: Peter Zijlstra (Intel) Acked-by: Bjorn Helgaas Link: https://lkml.kernel.org/r/20200313183608.2646-1-logang@deltatee.com --- 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 a823b4b..81dc7ac 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);