Files
linux/drivers/net/ethernet/sfc
Edward Cree 470152d76b sfc: fix crash when reading stats while NIC is resetting
[ Upstream commit d1b355438b ]

efx_net_stats() (.ndo_get_stats64) can be called during an ethtool
 selftest, during which time nic_data->mc_stats is NULL as the NIC has
 been fini'd.  In this case do not attempt to fetch the latest stats
 from the hardware, else we will crash on a NULL dereference:
    BUG: kernel NULL pointer dereference, address: 0000000000000038
    RIP efx_nic_update_stats
    abridged calltrace:
    efx_ef10_update_stats_pf
    efx_net_stats
    dev_get_stats
    dev_seq_printf_stats
Skipping the read is safe, we will simply give out stale stats.
To ensure that the free in efx_ef10_fini_nic() does not race against
 efx_ef10_update_stats_pf(), which could cause a TOCTTOU bug, take the
 efx->stats_lock in fini_nic (it is already held across update_stats).

Fixes: d3142c193d ("sfc: refactor EF10 stats handling")
Reviewed-by: Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>
Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-07-11 19:39:31 +02:00
..
2020-07-27 12:26:55 -07:00
2023-06-28 11:14:12 +02:00
2023-06-28 11:14:12 +02:00
2023-06-28 11:14:12 +02:00
2020-07-27 12:26:55 -07:00
2021-04-14 13:55:07 -07:00
2020-07-27 12:26:55 -07:00
2023-02-16 12:03:12 +01:00
2023-02-16 12:03:12 +01:00
2023-02-16 12:03:12 +01:00
2020-09-11 17:15:22 -07:00
2020-09-11 17:15:22 -07:00
2022-07-19 13:37:04 -07:00
2023-02-16 12:03:12 +01:00
2023-02-16 12:03:12 +01:00
2022-05-04 11:18:08 +01:00
2020-09-11 17:15:22 -07:00
2023-06-09 10:47:55 +02:00
2023-06-28 11:14:12 +02:00
2023-06-28 11:14:12 +02:00