CVE-2023-54156: sfc: fix crash when reading stats while NIC is resetting
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
sfc: fix crash when reading stats while NIC is resetting
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_statsSkipping 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).
The Linux kernel CVE team has assigned CVE-2023-54156 to this issue.
Affected and fixed versions
===========================
Issue introduced in 5.9 with commit d3142c193dca9a2f6878f4128ce1aaf221bb3f99 and fixed in 5.10.188 with commit cb1aa7cc562cab6a87ea33574c8c65f2d2fd7aeb Issue introduced in 5.9 with commit d3142c193dca9a2f6878f4128ce1aaf221bb3f99 and fixed in 5.15.121 with commit 91f4ef204e731565afdc6c2a7fcf509a3fd6fd67 Issue introduced in 5.9 with commit d3142c193dca9a2f6878f4128ce1aaf221bb3f99 and fixed in 6.1.39 with commit 446f5567934331923d0aec4ce045e4ecb0174aae Issue introduced in 5.9 with commit d3142c193dca9a2f6878f4128ce1aaf221bb3f99 and fixed in 6.3.13 with commit 470152d76b3ed107d172ea46acc4bfa941f20b4b Issue introduced in 5.9 with commit d3142c193dca9a2f6878f4128ce1aaf221bb3f99 and fixed in 6.4.4 with commit aba32b4c58112960c0c708703ca6b44dc8944082 Issue introduced in 5.9 with commit d3142c193dca9a2f6878f4128ce1aaf221bb3f99 and fixed in 6.5 with commit d1b355438b8325a486f087e506d412c4e852f37b
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2023-54156
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/net/ethernet/sfc/ef10.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/cb1aa7cc562cab6a87ea33574c8c65f2d2fd7aeb https://git.kernel.org/stable/c/91f4ef204e731565afdc6c2a7fcf509a3fd6fd67 https://git.kernel.org/stable/c/446f5567934331923d0aec4ce045e4ecb0174aae https://git.kernel.org/stable/c/470152d76b3ed107d172ea46acc4bfa941f20b4b https://git.kernel.org/stable/c/aba32b4c58112960c0c708703ca6b44dc8944082 https://git.kernel.org/stable/c/d1b355438b8325a486f087e506d412c4e852f37b