forcedeth: fix UAF of txrx_stats in nv_remove
authorChenguang Zhao <zhaochenguang@kylinos.cn>
Thu, 23 Jul 2026 09:26:37 +0000 (17:26 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 28 Jul 2026 00:52:50 +0000 (17:52 -0700)
commit22666ba1420164753d7b0f5a841986b25ace5435
tree8c250ea86237bec95ca750ee7fb956b000ca79d5
parent5546da86894d5906f131b05890705a7abf949d84
forcedeth: fix UAF of txrx_stats in nv_remove

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>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Link: https://patch.msgid.link/20260723092637.2135095-1-chenguang.zhao@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/nvidia/forcedeth.c