Message ID | 20230415081227.7463-1-duoming@zju.edu.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp902597vqo; Sat, 15 Apr 2023 01:24:35 -0700 (PDT) X-Google-Smtp-Source: AKy350YNT8VQyIigtS0eBPCvZypA47WEsWQGkETyYFP7lYlqa2LICNj3kqaQb7I48iotL4VG9krY X-Received: by 2002:a05:6a00:2341:b0:633:88de:7272 with SMTP id j1-20020a056a00234100b0063388de7272mr12354493pfj.2.1681547075666; Sat, 15 Apr 2023 01:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681547075; cv=none; d=google.com; s=arc-20160816; b=fq9wb3HHZULBEhcxHZCjvfTD6dzskAB7b0LsmQeZ8LpD1JQDC/OnTH8h4XeM3rl+Rg W8bN2Kz6LC8M2swaD9hd/JxdDc5VKRxd+G0rIUm/mvtsLILhf+Nf9ALEu6XqRIHmca+k nn/4xFq4YVlYTtU6bdElxC7CfawCqIvnmOMIYmvDGIlewj5YH/AiKh/lWk1MllJiq5lF w6KrHpvtqW/z26v+yr7Lzj12uCb6eFH0Qtu2I3SEaVZtG0SgBmKOVPwnaY5MnGIj+2hG iMn316gljDvMiugVGVLyUZM/MEpjEv68ADoPj++adaVc4A1lBa8tfz0JEUDp6VO7KUmI EmOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=TAysAFUbIcoQf0oAT4xQS6rinfm9AcH2RU8mkOIrmm4=; b=OqeK2Iughlf5nwBO9SK6up52WNd+1UdlQTNRhtb8danToBaftHIF8cIaVglLmlkKHg 4jrAMstxJZ9UMhiyxWl2Buwi0msJpnXMZaLAfudUpgfNVzmVa1dkH87ZV5YN15WVQpKE f2fKHyOX06dOZRLPjPdi/yXj6c9e6uU/ARsu3guuORH2MA20PxAAca82boyoVaK8AMR+ 9fXfdO7WILWqBA0QU1FaGZNagUs18gnKLqlCOaFKx5K2TZIRgQhWHTgy3h9puMLE0Vwy Jy9cTyXGH6PFHbH/9otuH8cpKa8FuRIrW0sZPJBqLOh3NKPT52H2PY+C9H+FT8DGvjur Zt4A== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q19-20020aa78433000000b0063724ddd779si6344522pfn.313.2023.04.15.01.24.22; Sat, 15 Apr 2023 01:24:35 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbjDOIM7 (ORCPT <rfc822;yuanzuo1009@gmail.com> + 99 others); Sat, 15 Apr 2023 04:12:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjDOIM5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 15 Apr 2023 04:12:57 -0400 Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [20.228.234.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0E8895260; Sat, 15 Apr 2023 01:12:53 -0700 (PDT) Received: from ubuntu.localdomain (unknown [106.117.97.24]) by mail-app4 (Coremail) with SMTP id cS_KCgAXHQprXDpkH3cQAA--.9359S2; Sat, 15 Apr 2023 16:12:37 +0800 (CST) From: Duoming Zhou <duoming@zju.edu.cn> To: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, pabeni@redhat.com, kuba@kernel.org, edumazet@google.com, davem@davemloft.net, rajur@chelsio.com, Duoming Zhou <duoming@zju.edu.cn> Subject: [PATCH RESEND net] cxgb4: fix use after free bugs caused by circular dependency problem Date: Sat, 15 Apr 2023 16:12:27 +0800 Message-Id: <20230415081227.7463-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_KCgAXHQprXDpkH3cQAA--.9359S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Ar48CF1fWr18Ar1fuF4kWFg_yoW8ZFW5pr s3Zr9rJw48Xa1UtF4UXw4ktFyqk3Z5trZ8KF1fG3yfu3Z7AFnIkFyDKay8WFW5JFW8Ar9r Aw48Zr98GFZYk3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkq14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK67AK6r43 MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0E wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JV WxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAI cVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbnjjDUUUUU== X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAwIGAWQ5a9oSIAAwso X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1763229906464078485?= X-GMAIL-MSGID: =?utf-8?q?1763229906464078485?= |
Series |
[RESEND,net] cxgb4: fix use after free bugs caused by circular dependency problem
|
|
Commit Message
Duoming Zhou
April 15, 2023, 8:12 a.m. UTC
The flower_stats_timer can schedule flower_stats_work and
flower_stats_work can also arm the flower_stats_timer. The
process is shown below:
----------- timer schedules work ------------
ch_flower_stats_cb() //timer handler
schedule_work(&adap->flower_stats_work);
----------- work arms timer ------------
ch_flower_stats_handler() //workqueue callback function
mod_timer(&adap->flower_stats_timer, ...);
When the cxgb4 device is detaching, the timer and workqueue
could still be rearmed. The process is shown below:
(cleanup routine) | (timer and workqueue routine)
remove_one() |
free_some_resources() | ch_flower_stats_cb() //timer
cxgb4_cleanup_tc_flower() | schedule_work()
del_timer_sync() |
| ch_flower_stats_handler() //workqueue
| mod_timer()
cancel_work_sync() |
kfree(adapter) //FREE | ch_flower_stats_cb() //timer
| adap->flower_stats_work //USE
This patch changes del_timer_sync() to timer_shutdown_sync(),
which could prevent rearming of the timer from the workqueue.
Fixes: e0f911c81e93 ("cxgb4: fetch stats for offloaded tc flower flows")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hello: This patch was applied to netdev/net.git (main) by Paolo Abeni <pabeni@redhat.com>: On Sat, 15 Apr 2023 16:12:27 +0800 you wrote: > The flower_stats_timer can schedule flower_stats_work and > flower_stats_work can also arm the flower_stats_timer. The > process is shown below: > > ----------- timer schedules work ------------ > ch_flower_stats_cb() //timer handler > schedule_work(&adap->flower_stats_work); > > [...] Here is the summary with links: - [RESEND,net] cxgb4: fix use after free bugs caused by circular dependency problem https://git.kernel.org/netdev/net/c/e50b9b9e8610 You are awesome, thank you!
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c index dd9be229819..d3541159487 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c @@ -1135,7 +1135,7 @@ void cxgb4_cleanup_tc_flower(struct adapter *adap) return; if (adap->flower_stats_timer.function) - del_timer_sync(&adap->flower_stats_timer); + timer_shutdown_sync(&adap->flower_stats_timer); cancel_work_sync(&adap->flower_stats_work); rhashtable_destroy(&adap->flower_tbl); adap->tc_flower_initialized = false;