CVE-2024-40979: wifi: ath12k: fix kernel crash during resume
In the Linux kernel, the following vulnerability has been resolved:
wifi: ath12k: fix kernel crash during resume
Currently during resume, QMI target memory is not properly handled, resulting in kernel crash in case DMA remap is not supported:
BUG: Bad page state in process kworker/u16:54 pfn:36e80 page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x36e80 page dumped because: nonzero refcount Call Trace: badpage freepageisbadreport freepagesok freepages dmadirectfree dmafreeattrs ath12kqmifreetargetmemchunk ath12kqmimsgmemrequestcb
The reason is: Once ath12k module is loaded, firmware sends memory request to host. In case DMA remap not supported, ath12k refuses the first request due to failure in allocating with large segment size:
ath12kpci 0000:04:00.0: qmi firmware request memory request ath12kpci 0000:04:00.0: qmi mem seg type 1 size 7077888 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 8454144 ath12kpci 0000:04:00.0: qmi dma allocation failed (7077888 B type 1), will try later with small size ath12kpci 0000:04:00.0: qmi delays memrequest 2 ath12kpci 0000:04:00.0: qmi firmware request memory request
Later firmware comes back with more but small segments and allocation succeeds:
ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 262144 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 524288 ath12kpci 0000:04:00.0: qmi mem seg type 4 size 65536 ath12kpci 0000:04:00.0: qmi mem seg type 1 size 524288
Now ath12k is working. If suspend is triggered, firmware will be reloaded during resume. As same as before, firmware requests two large segments at first. In ath12kqmimsgmemrequestcb() segment count and size are assigned:
ab->qmi.memsegcount == 2 ab->qmi.targetmem[0].size == 7077888 ab->qmi.targetmem[1].size == 8454144
Then allocation failed like before and ath12kqmifreetargetmemchunk() is called to free all allocated segments. Note the first segment is skipped because its v.addr is cleared due to allocation failure:
chunk->v.addr = dmaalloccoherent()
Also note that this leaks that segment because it has not been freed.
While freeing the second segment, a size of 8454144 is passed to dmafreecoherent(). However remember that this segment is allocated at the first time firmware is loaded, before suspend. So its real size is 524288, much smaller than 8454144. As a result kernel found we are freeing some memory which is in use and thus cras ---truncated---
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 5.10.223-1Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.25-1Fixed in 6.12.27-1
Event History
Frequently Asked Questions
What is the severity of CVE-2024-40979?
CVE-2024-40979 has been classified as a kernel crash vulnerability that can lead to system instability.
How do I fix CVE-2024-40979?
To fix CVE-2024-40979, update the Linux kernel to versions 5.10.223-1, 5.10.226-1, 6.1.123-1, 6.1.128-1, 6.12.12-1, or 6.12.13-1.
What systems are affected by CVE-2024-40979?
CVE-2024-40979 affects systems running specific versions of the Linux kernel that did not properly handle QMI target memory during resume.
What causes the issue in CVE-2024-40979?
The issue in CVE-2024-40979 is caused by improper handling of QMI target memory during system resume, specifically when DMA remap is not supported.
Is there a workaround for CVE-2024-40979?
There is no known workaround for CVE-2024-40979 aside from applying the recommended kernel updates.