Message ID | 20230309035641.3439953-1-zyytlz.wz@163.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp84110wrd; Wed, 8 Mar 2023 20:09:33 -0800 (PST) X-Google-Smtp-Source: AK7set8BAY+vmzOvxVu8j0pFT4Rmh4MHczWWQwAe91GxgGwYQgbdKWq1+0ReQKP0F9fXgblECtnF X-Received: by 2002:a17:90a:1911:b0:234:b8cb:512b with SMTP id 17-20020a17090a191100b00234b8cb512bmr20403280pjg.30.1678334973074; Wed, 08 Mar 2023 20:09:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678334973; cv=none; d=google.com; s=arc-20160816; b=sv7BhF4BMuwUDwfS+udJVo7USvsc3eWzEjkdCNK8qpEpyzov7xat4aTmL5MUDpWz2H gBfTfmXUoWrLenMZ2xDRWcxRC56GTMwfHYRPxkLRmGo4edXpdu3POBgauPbyYQQ1a3DC TRrlwANaWX39FXu4cIZJ6EUmHnCnn3bzGbWWcDcvtWQdMM/UlugYVebUI3YafoxNOsvY OUd2zwB9oOYW8n1QGjvolGjupjn5zYccl32tkA5JEgS9Wu4fD8IobJk5zr/q4rqQY+iL j6HsnSCV5oFbW+/+8SATVVAvKx+QXTrUnI5U5iIFfEazSFLAQhFgHBqa9fvgonBoD9Pg WMww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=uOlqg7qHm1VRJbAdquIECP19cN/BzkUoVyyDhvoLGiM=; b=D55EWXd1pOugOUyPcLVLikVLKa9oH+vZHnEdjsrh3dlUZAFQlb34Z0daNwd47yCKDS FxpPls43baA3FKXf64EHQGtTKxknFk9eKHAfukG+LekqHPFWGoobHKRNKHbw3n9Nn1BA EBBOeZ+rbyQoxrJMYgaWdK2Mtbr+02NH0RMDCmlVT3gJdWpD3cpRdajiclbqovLd8aa8 8ujTMcwPFw+iCksfQZSnMMAbHadJn5h7MyTPCd5py5Icn3sw5VDnnPHt6dQZwtWFStEV GOvhkK1JHMFntJVKdpTz3YZu0Zgvjlsjo9hj+xDZBW3YAbugHH4YKjIEptXG8/N/176M 34fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=V2p+AtVv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ie21-20020a17090b401500b0023747b030e7si1078271pjb.105.2023.03.08.20.09.18; Wed, 08 Mar 2023 20:09:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=V2p+AtVv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbjCID5k (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Wed, 8 Mar 2023 22:57:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbjCID5i (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 8 Mar 2023 22:57:38 -0500 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 485D7D3082; Wed, 8 Mar 2023 19:57:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=uOlqg 7qHm1VRJbAdquIECP19cN/BzkUoVyyDhvoLGiM=; b=V2p+AtVvV3jpQw8CIIAhV 7wfI/mK3YfaiSzgepuVWkNnq9e55y+NxrFtr65T0wiAecCoIzdtI/roro/c49RWy Vd+0D1qvUdKZs7PZc85stpla5PaPzZ+RYjRFGusd+Da9+g3bfmRfzApYHh2fi9pO 73t1S5mpXsIYcWW95ms1OA= Received: from leanderwang-LC2.localdomain (unknown [111.206.145.21]) by zwqz-smtp-mta-g4-2 (Coremail) with SMTP id _____wBnDLX6WAlk3EWhCg--.54307S2; Thu, 09 Mar 2023 11:56:42 +0800 (CST) From: Zheng Wang <zyytlz.wz@163.com> To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, hackerzheng666@gmail.com, 1395428693sheep@gmail.com, alex000young@gmail.com, Zheng Wang <zyytlz.wz@163.com> Subject: [PATCH] net: calxeda: fix race condition in xgmac_remove due to unfinshed work Date: Thu, 9 Mar 2023 11:56:41 +0800 Message-Id: <20230309035641.3439953-1-zyytlz.wz@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wBnDLX6WAlk3EWhCg--.54307S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jry5Kw1kAF18GF1fCr45Wrg_yoWfuFbEga s2vF1xWa1UXF1vkw4vkr4UZry8tF1Dur4rZFW0gryY93sxJr17Xrs7uF9rJF45W3yDGry3 GFnxArW0yw1UtjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRKBT5JUUUUU== X-Originating-IP: [111.206.145.21] X-CM-SenderInfo: h2113zf2oz6qqrwthudrp/1tbiGgEtU1aEEgnYDwAAs7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759861772823912845?= X-GMAIL-MSGID: =?utf-8?q?1759861772823912845?= |
Series |
net: calxeda: fix race condition in xgmac_remove due to unfinshed work
|
|
Commit Message
Zheng Wang
March 9, 2023, 3:56 a.m. UTC
In xgmac_probe, the priv->tx_timeout_work is bound with
xgmac_tx_timeout_work. In xgmac_remove, if there is an
unfinished work, there might be a race condition that
priv->base was written byte after iounmap it.
Fix it by finishing the work before cleanup.
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
---
drivers/net/ethernet/calxeda/xgmac.c | 1 +
1 file changed, 1 insertion(+)
Comments
Yunsheng Lin <linyunsheng@huawei.com> 于2023年3月9日周四 14:24写道: > > On 2023/3/9 11:56, Zheng Wang wrote: > > In xgmac_probe, the priv->tx_timeout_work is bound with > > xgmac_tx_timeout_work. In xgmac_remove, if there is an > > unfinished work, there might be a race condition that > > priv->base was written byte after iounmap it. > > > > Fix it by finishing the work before cleanup. > > This should go to net branch, so title should be: > > [PATCH net] net: calxeda: fix race condition in xgmac_remove due to unfinshed work > Sorry for the confusion. > From history commit, it seems more common to use "net: calxedaxgmac" instead of > "net: calxeda", I am not sure which one is better. > > Also there should be a Fixes tag for net branch, maybe: > > Fixes: 8746f671ef04 ("net: calxedaxgmac: fix race between xgmac_tx_complete and xgmac_tx_err") > > Yes, I was eager to report the fix and ignored that. Thanks for pointing that out. > > > > Signed-off-by: Zheng Wang <zyytlz.wz@163.com> > > --- > > drivers/net/ethernet/calxeda/xgmac.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c > > index f4f87dfa9687..94c3804001e3 100644 > > --- a/drivers/net/ethernet/calxeda/xgmac.c > > +++ b/drivers/net/ethernet/calxeda/xgmac.c > > @@ -1831,6 +1831,7 @@ static int xgmac_remove(struct platform_device *pdev) > > /* Free the IRQ lines */ > > free_irq(ndev->irq, ndev); > > free_irq(priv->pmt_irq, ndev); > > + cancel_work_sync(&priv->tx_timeout_work); > > It seems the blow function need to stop the dev_watchdog() from > calling dev->netdev_ops->ndo_tx_timeout before calling > cancel_work_sync(&priv->tx_timeout_work), otherwise the > dev_watchdog() may trigger the priv->tx_timeout_work to run again. > > netif_carrier_off(ndev); > netif_tx_disable(ndev); > > > > > unregister_netdev(ndev); > > netif_napi_del(&priv->napi); > > Yes, I agree with that. Thanks for your advice. I learned a lot from it. Best regards, Zheng
Yunsheng Lin <linyunsheng@huawei.com> 于2023年3月9日周四 14:27写道: > > On 2023/3/9 14:23, Yunsheng Lin wrote: > > On 2023/3/9 11:56, Zheng Wang wrote: > >> In xgmac_probe, the priv->tx_timeout_work is bound with > >> xgmac_tx_timeout_work. In xgmac_remove, if there is an > >> unfinished work, there might be a race condition that > >> priv->base was written byte after iounmap it. > >> > >> Fix it by finishing the work before cleanup. > > > > This should go to net branch, so title should be: > > > > [PATCH net] net: calxeda: fix race condition in xgmac_remove due to unfinshed work > > typo error: > unfinshed -> unfinished > Got it. Will correct it in the next version of patch. Thanks, Zheng
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c index f4f87dfa9687..94c3804001e3 100644 --- a/drivers/net/ethernet/calxeda/xgmac.c +++ b/drivers/net/ethernet/calxeda/xgmac.c @@ -1831,6 +1831,7 @@ static int xgmac_remove(struct platform_device *pdev) /* Free the IRQ lines */ free_irq(ndev->irq, ndev); free_irq(priv->pmt_irq, ndev); + cancel_work_sync(&priv->tx_timeout_work); unregister_netdev(ndev); netif_napi_del(&priv->napi);