CVE-2024-40979

Source
https://nvd.nist.gov/vuln/detail/CVE-2024-40979
Import Source
https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-40979.json
JSON Data
https://api.osv.dev/v1/vulns/CVE-2024-40979
Related
Published
2024-07-12T13:15:19Z
Modified
2024-11-30T21:45:50.074711Z
Summary
[none]
Details

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 ath12kqmimsgmemrequest_cb

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 ath12k_pci 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 ath12k_pci 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 ath12kqmimsgmemrequest_cb() segment count and size are assigned:

ab->qmi.mem_seg_count == 2
ab->qmi.target_mem[0].size == 7077888
ab->qmi.target_mem[1].size == 8454144

Then allocation failed like before and ath12kqmifreetargetmem_chunk() 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 = dma_alloc_coherent()

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---

References

Affected packages

Debian:13 / linux

Package

Name
linux
Purl
pkg:deb/debian/linux?arch=source

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
6.9.7-1

Affected versions

6.*

6.1.27-1
6.1.37-1
6.1.38-1
6.1.38-2~bpo11+1
6.1.38-2
6.1.38-3
6.1.38-4~bpo11+1
6.1.38-4
6.1.52-1
6.1.55-1~bpo11+1
6.1.55-1
6.1.64-1
6.1.66-1
6.1.67-1
6.1.69-1~bpo11+1
6.1.69-1
6.1.76-1~bpo11+1
6.1.76-1
6.1.82-1
6.1.85-1
6.1.90-1~bpo11+1
6.1.90-1
6.1.94-1~bpo11+1
6.1.94-1
6.1.98-1
6.1.99-1
6.1.106-1
6.1.106-2
6.1.106-3
6.1.112-1
6.1.115-1
6.1.119-1
6.3.1-1~exp1
6.3.2-1~exp1
6.3.4-1~exp1
6.3.5-1~exp1
6.3.7-1~bpo12+1
6.3.7-1
6.3.11-1
6.4~rc6-1~exp1
6.4~rc7-1~exp1
6.4.1-1~exp1
6.4.4-1~bpo12+1
6.4.4-1
6.4.4-2
6.4.4-3~bpo12+1
6.4.4-3
6.4.11-1
6.4.13-1
6.5~rc4-1~exp1
6.5~rc6-1~exp1
6.5~rc7-1~exp1
6.5.1-1~exp1
6.5.3-1~bpo12+1
6.5.3-1
6.5.6-1
6.5.8-1
6.5.10-1~bpo12+1
6.5.10-1
6.5.13-1
6.6.3-1~exp1
6.6.4-1~exp1
6.6.7-1~exp1
6.6.8-1
6.6.9-1
6.6.11-1
6.6.13-1~bpo12+1
6.6.13-1
6.6.15-1
6.6.15-2
6.7-1~exp1
6.7.1-1~exp1
6.7.4-1~exp1
6.7.7-1
6.7.9-1
6.7.9-2
6.7.12-1~bpo12+1
6.7.12-1
6.8.9-1
6.8.11-1
6.8.12-1~bpo12+1
6.8.12-1
6.9.2-1~exp1
6.9.7-1~bpo12+1

Ecosystem specific

{
    "urgency": "not yet assigned"
}