ravb: Fix potential use-after-free in ravb_rx_gbeth()
authorYueHaibing <yuehaibing@huawei.com>
Sat, 3 Dec 2022 09:29:41 +0000 (17:29 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 6 Dec 2022 11:37:25 +0000 (12:37 +0100)
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>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20221203092941.10880-1-yuehaibing@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/renesas/ravb_main.c

index 6bc9233..33f723a 100644 (file)
@@ -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;
                        }
                }