Message ID | 20230309100248.3831498-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 v21csp210014wrd; Thu, 9 Mar 2023 02:25:35 -0800 (PST) X-Google-Smtp-Source: AK7set8SwBqpgcU1QEvhP34fIJsvCLLeRvYZGRnM3NYPu75m7QxDUPG7GCZhDQl6Tb13MCdc0ttS X-Received: by 2002:a05:6a21:6d9f:b0:cd:a334:a531 with SMTP id wl31-20020a056a216d9f00b000cda334a531mr27352593pzb.62.1678357535701; Thu, 09 Mar 2023 02:25:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678357535; cv=none; d=google.com; s=arc-20160816; b=Y5qhRxEeTBDhN8V/iEJdo4/KFrmWY1cdzncL+2eDahccMJ2HQqRa58Nt3MkFE4fKLb fRZ1yo5U0/HFQU5Ijnl+5NhZG+PMYpeFrA73PXk88IfQfIkvJFEbxI3/7r5OgEXbA30a n3j5rkw+gKDw65s23E/fbhZhYYqIqThpOCwDgeE4ulxPe0YdcWwMSMDrzCnoknWYa1cS AfyVunmGeQnlymU5UjUvwQSgUUkd7X2j6JxUGAnrKYLwZ/rM/D6h7GOu140Havs2njpp KKhrmtWHzXYp0R5//tQy/rrtiyhjr7UknKVO5PI/TV/PugI3p16qtn683xQbGhHLGHy6 KmHw== 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=qovOwvicZU4vTpXXhGsBzD0cFYCZA70jXWH/VBFx1Vs=; b=YcX38RI9h86ljGVUW7eZqlb+wxdOV0IHbG4prGl0KMcSX+2KYaqDhR2sC+OQhWW1/P Y/bwgKQMPJq3YJ4oRpA6PiLOx+IdYfh2oLUCvvGJBOmE2uk7NmGXDWFQcH8C5HgiSkZK QqnR/7xsw3b+uxTWgWfHRyigXnJHFDQvWicbvD3KMhIU/5mrFBSOzoGS5poDloVKy/QB BGns2EFwrqQB/Xf4SRQx4Qb5ffycyyCbJIlfGkTD/DVzR8yFv82JCYQsFJ//zo+up5R2 Be7MoJvHrAj/F70YA5eOKRTz+3kdO9J+XZAaEl3opR/uTQ6atX79/Xm58ANmSU7Mnkl4 IoGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=T4NL3WGB; 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 q184-20020a6343c1000000b004fb94ce0f51si16043905pga.795.2023.03.09.02.25.22; Thu, 09 Mar 2023 02:25:35 -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=T4NL3WGB; 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 S229963AbjCIKD7 (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Thu, 9 Mar 2023 05:03:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjCIKD4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Mar 2023 05:03:56 -0500 Received: from m12.mail.163.com (m12.mail.163.com [123.126.96.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 986AC6427C; Thu, 9 Mar 2023 02:03:51 -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=qovOw vicZU4vTpXXhGsBzD0cFYCZA70jXWH/VBFx1Vs=; b=T4NL3WGBYewtn8ET/4KJa bPo8OWrO5xx4K0Uh28ZSgp89yZllxfqXgdbNjYjpqeED0u4DHVGJpu7ZC+YtygQH 96SBMJm8vUNCP2oTtDdyeCsx/Mho5ozUyTkn5cChzrnlfyzOgi4pQm/wvkFDoeO6 ffInWOOOSfnge1WSuO9EtQ= Received: from leanderwang-LC2.localdomain (unknown [111.206.145.21]) by smtp17 (Coremail) with SMTP id NdxpCgDn_nrJrglkhu3eGw--.53030S2; Thu, 09 Mar 2023 18:02:49 +0800 (CST) From: Zheng Wang <zyytlz.wz@163.com> To: s.shtylyov@omp.ru Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, hackerzheng666@gmail.com, 1395428693sheep@gmail.com, alex000young@gmail.com, Zheng Wang <zyytlz.wz@163.com> Subject: [PATCH net] net: ravb: Fix possible UAF bug in ravb_remove Date: Thu, 9 Mar 2023 18:02:48 +0800 Message-Id: <20230309100248.3831498-1-zyytlz.wz@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: NdxpCgDn_nrJrglkhu3eGw--.53030S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrKr48Xw4UKFW3KFW7Aw4fXwb_yoWDCrbEga 4qvr1fK3y5Gr1vka10ka13urW2yr1kX34rCa17K3yaqa9rAw13Jrs5ZrnxXr1UuwsrXF9x Wrn3tF4Iyw1jvjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRZZ2a3UUUUU== X-Originating-IP: [111.206.145.21] X-CM-SenderInfo: h2113zf2oz6qqrwthudrp/1tbiXQktU1WBo2lZogAAsP 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?1759885431147453616?= X-GMAIL-MSGID: =?utf-8?q?1759885431147453616?= |
Series |
[net] net: ravb: Fix possible UAF bug in ravb_remove
|
|
Commit Message
Zheng Wang
March 9, 2023, 10:02 a.m. UTC
In ravb_probe, priv->work was bound with ravb_tx_timeout_work.
If timeout occurs, it will start the work. And if we call
ravb_remove without finishing the work, ther may be a use
after free bug on ndev.
Fix it by finishing the job before cleanup in ravb_remove.
Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
---
drivers/net/ethernet/renesas/ravb_main.c | 1 +
1 file changed, 1 insertion(+)
Comments
Hello! On 3/9/23 1:02 PM, Zheng Wang wrote: > In ravb_probe, priv->work was bound with ravb_tx_timeout_work. > If timeout occurs, it will start the work. And if we call > ravb_remove without finishing the work, ther may be a use > after free bug on ndev. Have you actually encountered it? > Fix it by finishing the job before cleanup in ravb_remove. > > Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") Hm... sorry about that. :-) > Signed-off-by: Zheng Wang <zyytlz.wz@163.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> [...] > diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c > index 0f54849a3823..07a08e72f440 100644 > --- a/drivers/net/ethernet/renesas/ravb_main.c > +++ b/drivers/net/ethernet/renesas/ravb_main.c > @@ -2892,6 +2892,7 @@ static int ravb_remove(struct platform_device *pdev) > struct ravb_private *priv = netdev_priv(ndev); > const struct ravb_hw_info *info = priv->info; > > + cancel_work_sync(&priv->work); I think we need an empty line here... > /* Stop PTP Clock driver */ > if (info->ccc_gac) > ravb_ptp_stop(ndev); MBR, Sergey
Sergey Shtylyov <s.shtylyov@omp.ru> 于2023年3月9日周四 23:47写道: > > Hello! > > On 3/9/23 1:02 PM, Zheng Wang wrote: > > > In ravb_probe, priv->work was bound with ravb_tx_timeout_work. > > If timeout occurs, it will start the work. And if we call > > ravb_remove without finishing the work, ther may be a use > > after free bug on ndev. > > Have you actually encountered it? Sorry, I haven't encountered it. All of the analysis is based on static analysis. > > > Fix it by finishing the job before cleanup in ravb_remove. > > > > Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") > > Hm... sorry about that. :-) > > > Signed-off-by: Zheng Wang <zyytlz.wz@163.com> > > Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> > > [...] > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c > > index 0f54849a3823..07a08e72f440 100644 > > --- a/drivers/net/ethernet/renesas/ravb_main.c > > +++ b/drivers/net/ethernet/renesas/ravb_main.c > > @@ -2892,6 +2892,7 @@ static int ravb_remove(struct platform_device *pdev) > > struct ravb_private *priv = netdev_priv(ndev); > > const struct ravb_hw_info *info = priv->info; > > > > + cancel_work_sync(&priv->work); > > I think we need an empty line here... Yes, will add it in the next version of patch. Best regards, Zheng > > > /* Stop PTP Clock driver */ > > if (info->ccc_gac) > > ravb_ptp_stop(ndev); >
Yunsheng Lin <linyunsheng@huawei.com> 于2023年3月10日周五 09:12写道: > > On 2023/3/9 18:02, Zheng Wang wrote: > > In ravb_probe, priv->work was bound with ravb_tx_timeout_work. > > If timeout occurs, it will start the work. And if we call > > ravb_remove without finishing the work, ther may be a use > > ther -> there > Sorry about the typo, will correct it in the next version. > > after free bug on ndev. > > > > Fix it by finishing the job before cleanup in ravb_remove. > > > > Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") > > Signed-off-by: Zheng Wang <zyytlz.wz@163.com> > > --- > > drivers/net/ethernet/renesas/ravb_main.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c > > index 0f54849a3823..07a08e72f440 100644 > > --- a/drivers/net/ethernet/renesas/ravb_main.c > > +++ b/drivers/net/ethernet/renesas/ravb_main.c > > @@ -2892,6 +2892,7 @@ static int ravb_remove(struct platform_device *pdev) > > struct ravb_private *priv = netdev_priv(ndev); > > const struct ravb_hw_info *info = priv->info; > > > > + cancel_work_sync(&priv->work); > > As your previous patch, I still do not see anything stopping > dev_watchdog() from calling dev->netdev_ops->ndo_tx_timeout > after cancel_work_sync(), maybe I missed something obvious > here? > Yes, that's a keyed suggestion. I was hurry to report the issue today so wrote with many mistakes. Thanks agagin for the advice. I will review other patch carefully. Best regards, Zheng > > > /* Stop PTP Clock driver */ > > if (info->ccc_gac) > > ravb_ptp_stop(ndev); > >
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0f54849a3823..07a08e72f440 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2892,6 +2892,7 @@ static int ravb_remove(struct platform_device *pdev) struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + cancel_work_sync(&priv->work); /* Stop PTP Clock driver */ if (info->ccc_gac) ravb_ptp_stop(ndev);