Message ID | 20221203092941.10880-1-yuehaibing@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1284551wrr; Sat, 3 Dec 2022 01:31:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf4SzxUUqeqvCUNxEqSjFmOjzA6iuHP4NNfiLfSHyG1Voab/N+Zo/B45EmdepctC2vAcwCXV X-Received: by 2002:a17:907:8dcc:b0:7b2:b5aa:f1e0 with SMTP id tg12-20020a1709078dcc00b007b2b5aaf1e0mr1319515ejc.54.1670059870375; Sat, 03 Dec 2022 01:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670059870; cv=none; d=google.com; s=arc-20160816; b=0gMSZRIQmXxACB/It59qZ87FA+moBG3R6SbUpeUJAsAM4SsiMmPuvMI5Zvk1tpxojK IuSahLjJFpFyB3NmwLwvzLU7sXnD7cHSpiUHzdAB2WKe5IS/CaYPo1morEbH1Ib2TP9I t74qZp33XrWIzymZXn4t00YaWo0FnWsST/uqWwZ5jGs0vQWdjby7uEVk3D3+ldpR1qQc wpc8lT8bRAUigNZdgW6afNf0g3kgUHOts/UDKS+jZkIzAgPVqwXQE8/SPv06enbQf6Gy aHM8e4713eOp3xmCCfhG2ifX9L8s07sbOsq7RRBGD59XulEwner3G4IDT+nbxtAtqZ9f 4xDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=3uKlaeXwBhmRxA3B/tuQA0745VGuYDNooDe4HAyNmGw=; b=T+sHq9yHeOruWz/X5+pLFzf/aiHfJVgYxdcjTgJ5uUsnYYBsnuboUNf02IRqr+KDmQ +3UIeTU79clHCVRrhIcxI8CV1prjxSONUt6LN9dZu+JgEi5mojh1J3n0fKkSoj5/zG3r TCrIONJ9zj+Mk0LGHZ/iE5ypX8vGwidKVV1OSLNdbQXyiIEZdzCHGrfc4SMzzZPYPhUC S7Ou168pGkurJzTiikoOj47kRCTXe/465MYeYAIF3Z/PNewpKm3hVYCtss64THmTruzE NA5ddTc4bN7mriCbO2DN1Kg7N9podsdUSFmooRwiFk6XUBOwarKvPCuqEMEwmIsD3OW8 eyzg== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xe8-20020a170907318800b0078d805901b1si8247287ejb.489.2022.12.03.01.30.44; Sat, 03 Dec 2022 01:31:10 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229468AbiLCJae (ORCPT <rfc822;lhua1029@gmail.com> + 99 others); Sat, 3 Dec 2022 04:30:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbiLCJac (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 3 Dec 2022 04:30:32 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25FCB5B86D; Sat, 3 Dec 2022 01:30:28 -0800 (PST) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NPPfG13NyzRnvp; Sat, 3 Dec 2022 17:29:42 +0800 (CST) Received: from localhost (10.174.179.215) by canpemm500007.china.huawei.com (7.192.104.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 3 Dec 2022 17:30:26 +0800 From: YueHaibing <yuehaibing@huawei.com> To: <s.shtylyov@omp.ru>, <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>, <phil.edworthy@renesas.com>, <biju.das.jz@bp.renesas.com>, <prabhakar.mahadev-lad.rj@bp.renesas.com> CC: <netdev@vger.kernel.org>, <linux-renesas-soc@vger.kernel.org>, <linux-kernel@vger.kernel.org>, YueHaibing <yuehaibing@huawei.com> Subject: [PATCH net] ravb: Fix potential use-after-free in ravb_rx_gbeth() Date: Sat, 3 Dec 2022 17:29:41 +0800 Message-ID: <20221203092941.10880-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500007.china.huawei.com (7.192.104.62) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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?1751184698651452668?= X-GMAIL-MSGID: =?utf-8?q?1751184698651452668?= |
Series |
[net] ravb: Fix potential use-after-free in ravb_rx_gbeth()
|
|
Commit Message
Yue Haibing
Dec. 3, 2022, 9:29 a.m. UTC
The skb is delivered to napi_gro_receive() which may free it, after calling this,
dereferencing skb may trigger use-after-free.
Fixes: 1c59eb678cbd ("ravb: Fillup ravb_rx_gbeth() stub")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/net/ethernet/renesas/ravb_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi YueHaibing, Thanks for the feedback. > Subject: [PATCH net] ravb: Fix potential use-after-free in > ravb_rx_gbeth() > > The skb is delivered to napi_gro_receive() which may free it, after > calling this, dereferencing skb may trigger use-after-free. Can you please reconfirm the changes you have done is actually fixing any issue? If yes, please provide the details. Current code, napi_gro_receive(&priv->napi[q], priv->rx_1st_skb); - stats->rx_bytes += priv->rx_1st_skb->len; + stats->rx_bytes += pkt_len; Note: I haven't tested your patch yet to see it cause any regression. Cheers, Biju > > Fixes: 1c59eb678cbd ("ravb: Fillup ravb_rx_gbeth() stub") > Signed-off-by: YueHaibing <yuehaibing@huawei.com> > --- > drivers/net/ethernet/renesas/ravb_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c > b/drivers/net/ethernet/renesas/ravb_main.c > index 6bc923326268..33f723a9f471 100644 > --- a/drivers/net/ethernet/renesas/ravb_main.c > +++ b/drivers/net/ethernet/renesas/ravb_main.c > @@ -841,7 +841,7 @@ static bool ravb_rx_gbeth(struct net_device *ndev, > int *quota, int q) > napi_gro_receive(&priv->napi[q], > priv->rx_1st_skb); > stats->rx_packets++; > - stats->rx_bytes += priv->rx_1st_skb->len; > + stats->rx_bytes += pkt_len; > break; > } > } > -- > 2.34.1
Hi Biju, On Sat, Dec 3, 2022 at 11:29 AM Biju Das <biju.das.jz@bp.renesas.com> wrote: > > Subject: [PATCH net] ravb: Fix potential use-after-free in > > ravb_rx_gbeth() > > > > The skb is delivered to napi_gro_receive() which may free it, after > > calling this, dereferencing skb may trigger use-after-free. > > Can you please reconfirm the changes you have done is actually fixing any issue? > If yes, please provide the details. > > Current code, > > napi_gro_receive(&priv->napi[q], priv->rx_1st_skb); IIUIC, after this, priv->rx_1st_skb may have been freed... > > - stats->rx_bytes += priv->rx_1st_skb->len; ... so accessing priv->rx_1st_skb->len here may be a UAF. > + stats->rx_bytes += pkt_len; So this change looks correct to me, as pkt_len was stored to priv->rx_1st_skb->len using skb_put() before. Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> > > Note: I haven't tested your patch yet to see it cause any regression. > > Cheers, > Biju > > > > > Fixes: 1c59eb678cbd ("ravb: Fillup ravb_rx_gbeth() stub") > > Signed-off-by: YueHaibing <yuehaibing@huawei.com> > > --- > > drivers/net/ethernet/renesas/ravb_main.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c > > b/drivers/net/ethernet/renesas/ravb_main.c > > index 6bc923326268..33f723a9f471 100644 > > --- a/drivers/net/ethernet/renesas/ravb_main.c > > +++ b/drivers/net/ethernet/renesas/ravb_main.c > > @@ -841,7 +841,7 @@ static bool ravb_rx_gbeth(struct net_device *ndev, > > int *quota, int q) > > napi_gro_receive(&priv->napi[q], > > priv->rx_1st_skb); > > stats->rx_packets++; > > - stats->rx_bytes += priv->rx_1st_skb->len; > > + stats->rx_bytes += pkt_len; > > break; > > } > > } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi Geert, > Subject: Re: [PATCH net] ravb: Fix potential use-after-free in > ravb_rx_gbeth() > > Hi Biju, > > On Sat, Dec 3, 2022 at 11:29 AM Biju Das <biju.das.jz@bp.renesas.com> > wrote: > > > Subject: [PATCH net] ravb: Fix potential use-after-free in > > > ravb_rx_gbeth() > > > > > > The skb is delivered to napi_gro_receive() which may free it, after > > > calling this, dereferencing skb may trigger use-after-free. > > > > Can you please reconfirm the changes you have done is actually fixing > any issue? > > If yes, please provide the details. > > > > Current code, > > > > napi_gro_receive(&priv->napi[q], priv->rx_1st_skb); > > IIUIC, after this, priv->rx_1st_skb may have been freed... > > > > > - stats->rx_bytes += priv->rx_1st_skb->len; > > ... so accessing priv->rx_1st_skb->len here may be a UAF. > > > + stats->rx_bytes += pkt_len; > > So this change looks correct to me, as pkt_len was stored to > priv->rx_1st_skb->len using skb_put() before. Thanks for detailed explanation. It makes sense now. Cheers, Biju > > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> > > > > > Note: I haven't tested your patch yet to see it cause any regression. > > > > Cheers, > > Biju > > > > > > > > Fixes: 1c59eb678cbd ("ravb: Fillup ravb_rx_gbeth() stub") > > > Signed-off-by: YueHaibing <yuehaibing@huawei.com> > > > --- > > > drivers/net/ethernet/renesas/ravb_main.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c > > > b/drivers/net/ethernet/renesas/ravb_main.c > > > index 6bc923326268..33f723a9f471 100644 > > > --- a/drivers/net/ethernet/renesas/ravb_main.c > > > +++ b/drivers/net/ethernet/renesas/ravb_main.c > > > @@ -841,7 +841,7 @@ static bool ravb_rx_gbeth(struct net_device > > > *ndev, int *quota, int q) > > > napi_gro_receive(&priv->napi[q], > > > priv->rx_1st_skb); > > > stats->rx_packets++; > > > - stats->rx_bytes += priv->rx_1st_skb- > >len; > > > + stats->rx_bytes += pkt_len; > > > break; > > > } > > > } > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux- > m68k.org > > In personal conversations with technical people, I call myself a hacker. > But when I'm talking to journalists I just say "programmer" or something > like that. > -- Linus Torvalds
Hello: This patch was applied to netdev/net.git (master) by Paolo Abeni <pabeni@redhat.com>: On Sat, 3 Dec 2022 17:29:41 +0800 you wrote: > The skb is delivered to napi_gro_receive() which may free it, after calling this, > dereferencing skb may trigger use-after-free. > > Fixes: 1c59eb678cbd ("ravb: Fillup ravb_rx_gbeth() stub") > Signed-off-by: YueHaibing <yuehaibing@huawei.com> > --- > drivers/net/ethernet/renesas/ravb_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Here is the summary with links: - [net] ravb: Fix potential use-after-free in ravb_rx_gbeth() https://git.kernel.org/netdev/net/c/5a5a3e564de6 You are awesome, thank you!
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 6bc923326268..33f723a9f471 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -841,7 +841,7 @@ static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q) napi_gro_receive(&priv->napi[q], priv->rx_1st_skb); stats->rx_packets++; - stats->rx_bytes += priv->rx_1st_skb->len; + stats->rx_bytes += pkt_len; break; } }