CVE-2022-49061: net: ethernet: stmmac: fix altr_tse_pcs function when using a fixed-link
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
net: ethernet: stmmac: fix altr_tse_pcs function when using a fixed-link
When using a fixed-link, the altr_tse_pcs driver crashes due to null-pointer dereference as no phy_device is provided to tse_pcs_fix_mac_speed function. Fix this by adding a check for phy_dev before calling the tse_pcs_fix_mac_speed() function.
Also clean up the tse_pcs_fix_mac_speed function a bit. There is no need to check for splitter_base and sgmii_adapter_base because the driver will fail if these 2 variables are not derived from the device tree.
The Linux kernel CVE team has assigned CVE-2022-49061 to this issue.
Affected and fixed versions
===========================
Issue introduced in 4.8 with commit fb3bbdb859891e6bc27fd1afb3a07319f82c2ee4 and fixed in 5.4.190 with commit 7e59fdf9547c4f948d1d917ec7ffa5fb5ac53bdb Issue introduced in 4.8 with commit fb3bbdb859891e6bc27fd1afb3a07319f82c2ee4 and fixed in 5.10.112 with commit 08d5e3e954537931c8da7428034808d202e98299 Issue introduced in 4.8 with commit fb3bbdb859891e6bc27fd1afb3a07319f82c2ee4 and fixed in 5.15.35 with commit 62a48383ebe2e159fd68425dd3e16d4c6bd6599a Issue introduced in 4.8 with commit fb3bbdb859891e6bc27fd1afb3a07319f82c2ee4 and fixed in 5.17.4 with commit 6c020f05253df04c3480b586fe188a3582740049 Issue introduced in 4.8 with commit fb3bbdb859891e6bc27fd1afb3a07319f82c2ee4 and fixed in 5.18 with commit a6aaa00324240967272b451bfa772547bd576ee6
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-2022-49061
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/stmicro/stmmac/altr_tse_pcs.c drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.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/7e59fdf9547c4f948d1d917ec7ffa5fb5ac53bdb https://git.kernel.org/stable/c/08d5e3e954537931c8da7428034808d202e98299 https://git.kernel.org/stable/c/62a48383ebe2e159fd68425dd3e16d4c6bd6599a https://git.kernel.org/stable/c/6c020f05253df04c3480b586fe188a3582740049 https://git.kernel.org/stable/c/a6aaa00324240967272b451bfa772547bd576ee6