* [PATCH net] forcedeth: fix UAF of txrx_stats in nv_remove
@ 2026-07-23 9:26 Chenguang Zhao
2026-07-23 10:41 ` Vadim Fedorenko
2026-07-23 14:38 ` Zhu Yanjun
0 siblings, 2 replies; 3+ messages in thread
From: Chenguang Zhao @ 2026-07-23 9:26 UTC (permalink / raw)
To: rain.1986.08.12, zyjzyj2000, andrew+netdev, davem, edumazet, kuba,
pabeni
Cc: netdev, chenguang.zhao, Chenguang Zhao
From: Chenguang Zhao <zhaochenguang@kylinos.cn>
nv_remove() frees the per-CPU txrx_stats before unregister_netdev().
Until unregister completes, ndo_get_stats64, the NAPI/xmit data path,
and nv_close()/drain may still access txrx_stats, leading to a
use-after-free.
Free the stats only after unregister_netdev().
Fixes: f4b633b911fd ("forcedeth: use per cpu to collect xmit/recv statistics")
Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
---
drivers/net/ethernet/nvidia/forcedeth.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
index 5b0435d7bc39..106885bd0f6b 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -6187,9 +6187,11 @@ static void nv_remove(struct pci_dev *pci_dev)
struct net_device *dev = pci_get_drvdata(pci_dev);
struct fe_priv *np = netdev_priv(dev);
- free_percpu(np->txrx_stats);
-
+ /* txrx_stats is used by ndo_get_stats64 and the data path until
+ * unregister_netdevice() has completed.
+ */
unregister_netdev(dev);
+ free_percpu(np->txrx_stats);
nv_restore_mac_addr(pci_dev);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] forcedeth: fix UAF of txrx_stats in nv_remove
2026-07-23 9:26 [PATCH net] forcedeth: fix UAF of txrx_stats in nv_remove Chenguang Zhao
@ 2026-07-23 10:41 ` Vadim Fedorenko
2026-07-23 14:38 ` Zhu Yanjun
1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2026-07-23 10:41 UTC (permalink / raw)
To: Chenguang Zhao, rain.1986.08.12, zyjzyj2000, andrew+netdev, davem,
edumazet, kuba, pabeni
Cc: netdev, Chenguang Zhao
On 23/07/2026 10:26, Chenguang Zhao wrote:
> From: Chenguang Zhao <zhaochenguang@kylinos.cn>
>
> nv_remove() frees the per-CPU txrx_stats before unregister_netdev().
> Until unregister completes, ndo_get_stats64, the NAPI/xmit data path,
> and nv_close()/drain may still access txrx_stats, leading to a
> use-after-free.
>
> Free the stats only after unregister_netdev().
>
> Fixes: f4b633b911fd ("forcedeth: use per cpu to collect xmit/recv statistics")
> Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
> ---
> drivers/net/ethernet/nvidia/forcedeth.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
> index 5b0435d7bc39..106885bd0f6b 100644
> --- a/drivers/net/ethernet/nvidia/forcedeth.c
> +++ b/drivers/net/ethernet/nvidia/forcedeth.c
> @@ -6187,9 +6187,11 @@ static void nv_remove(struct pci_dev *pci_dev)
> struct net_device *dev = pci_get_drvdata(pci_dev);
> struct fe_priv *np = netdev_priv(dev);
>
> - free_percpu(np->txrx_stats);
> -
> + /* txrx_stats is used by ndo_get_stats64 and the data path until
> + * unregister_netdevice() has completed.
> + */
> unregister_netdev(dev);
> + free_percpu(np->txrx_stats);
>
> nv_restore_mac_addr(pci_dev);
>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] forcedeth: fix UAF of txrx_stats in nv_remove
2026-07-23 9:26 [PATCH net] forcedeth: fix UAF of txrx_stats in nv_remove Chenguang Zhao
2026-07-23 10:41 ` Vadim Fedorenko
@ 2026-07-23 14:38 ` Zhu Yanjun
1 sibling, 0 replies; 3+ messages in thread
From: Zhu Yanjun @ 2026-07-23 14:38 UTC (permalink / raw)
To: Chenguang Zhao, rain.1986.08.12, zyjzyj2000, andrew+netdev, davem,
edumazet, kuba, pabeni
Cc: netdev, Chenguang Zhao, yanjun.zhu@linux.dev
在 2026/7/23 2:26, Chenguang Zhao 写道:
> From: Chenguang Zhao <zhaochenguang@kylinos.cn>
>
> nv_remove() frees the per-CPU txrx_stats before unregister_netdev().
> Until unregister completes, ndo_get_stats64, the NAPI/xmit data path,
> and nv_close()/drain may still access txrx_stats, leading to a
> use-after-free.
>
> Free the stats only after unregister_netdev().
>
> Fixes: f4b633b911fd ("forcedeth: use per cpu to collect xmit/recv statistics")
> Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
Thanks a lot. I am fine with it.
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Zhu Yanjun
> ---
> drivers/net/ethernet/nvidia/forcedeth.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
> index 5b0435d7bc39..106885bd0f6b 100644
> --- a/drivers/net/ethernet/nvidia/forcedeth.c
> +++ b/drivers/net/ethernet/nvidia/forcedeth.c
> @@ -6187,9 +6187,11 @@ static void nv_remove(struct pci_dev *pci_dev)
> struct net_device *dev = pci_get_drvdata(pci_dev);
> struct fe_priv *np = netdev_priv(dev);
>
> - free_percpu(np->txrx_stats);
> -
> + /* txrx_stats is used by ndo_get_stats64 and the data path until
> + * unregister_netdevice() has completed.
> + */
> unregister_netdev(dev);
> + free_percpu(np->txrx_stats);
>
> nv_restore_mac_addr(pci_dev);
>
--
Best Regards,
Yanjun.Zhu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-23 14:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23 9:26 [PATCH net] forcedeth: fix UAF of txrx_stats in nv_remove Chenguang Zhao
2026-07-23 10:41 ` Vadim Fedorenko
2026-07-23 14:38 ` Zhu Yanjun
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.