CVE-2022-49569: spi: bcm2835: bcm2835_spi_handle_err(): fix NULL pointer deref for non DMA transfers
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
spi: bcm2835: bcm2835_spi_handle_err(): fix NULL pointer deref for non DMA transfers
In case a IRQ based transfer times out the bcm2835_spi_handle_err() function is called. Since commit 1513ceee70f2 ("spi: bcm2835: Drop dma_pending flag") the TX and RX DMA transfers are unconditionally canceled, leading to NULL pointer derefs if ctlr->dma_tx or ctlr->dma_rx are not set.
Fix the NULL pointer deref by checking that ctlr->dma_tx and ctlr->dma_rx are valid pointers before accessing them.
The Linux kernel CVE team has assigned CVE-2022-49569 to this issue.
Affected and fixed versions
===========================
Issue introduced in 5.4 with commit 1513ceee70f2bd523e025efe0c715328e1a43ffd and fixed in 5.4.208 with commit 76668d2a2f367d25ff448e6d7087406af7d7bb2b Issue introduced in 5.4 with commit 1513ceee70f2bd523e025efe0c715328e1a43ffd and fixed in 5.10.134 with commit 684896e675edd8b669fd3e9f547c5038222d85bc Issue introduced in 5.4 with commit 1513ceee70f2bd523e025efe0c715328e1a43ffd and fixed in 5.15.58 with commit 58466e05390043d2805685c70f55f3f59711bdf2 Issue introduced in 5.4 with commit 1513ceee70f2bd523e025efe0c715328e1a43ffd and fixed in 5.18.15 with commit 49ffa473218012e765682343de2052eb4c1f06a7 Issue introduced in 5.4 with commit 1513ceee70f2bd523e025efe0c715328e1a43ffd and fixed in 5.19 with commit 4ceaa684459d414992acbefb4e4c31f2dfc50641
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-49569
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/spi/spi-bcm2835.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/76668d2a2f367d25ff448e6d7087406af7d7bb2b https://git.kernel.org/stable/c/684896e675edd8b669fd3e9f547c5038222d85bc https://git.kernel.org/stable/c/58466e05390043d2805685c70f55f3f59711bdf2 https://git.kernel.org/stable/c/49ffa473218012e765682343de2052eb4c1f06a7 https://git.kernel.org/stable/c/4ceaa684459d414992acbefb4e4c31f2dfc50641