Vulnerability · Published Feb 26, 2025 · Assigned by Linux
CVE-2022-49607perf/core: Fix data race between perf_event_set_output() and perf_mmap_close()
Medium 4.7
In plain English
A medium-severity race condition in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.2% (higher than 8% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.
Official description
In the Linux kernel, the following vulnerability has been resolved: perf/core: Fix data race between perf_event_set_output() and perf_mmap_close() Yang Jihing reported a race between perf_event_set_output() and perf_mmap_close(): CPU1 CPU2 perf_mmap_close(e2) if (atomic_dec_and_test(&e2->rb->mmap_count)) // 1 - > 0 detach_rest = true ioctl(e1, IOC_SET_OUTPUT, e2) perf_event_set_output(e1, e2) ... list_for_each_entry_rcu(e, &e2->rb->event_list, rb_entry) ring_buffer_attach(e, NULL); // e1 isn't yet added and // therefore not detached ring_buffer_attach(e1, e2->rb) list_add_rcu(&e1->rb_entry, &e2->rb->event_list) After this; e1 is attached to an unmapped rb and a subsequent perf_mmap() will loop forever more: again: mutex_lock(&e->mmap_mutex); if (event->rb) { ... if (!atomic_inc_not_zero(&e->rb->mmap_count)) { ... mutex_unlock(&e->mmap_mutex); goto again; } } The loop in perf_mmap_close() holds e2->mmap_mutex, while the attach in perf_event_set_output() holds e1->mmap_mutex. As such there is no serialization to avoid this race. Change perf_event_set_output() to take both e1->mmap_mutex and e2->mmap_mutex to alleviate that problem. Additionally, have the loop in perf_mmap() detach the rb directly, this avoids having to wait for the concurrent perf_mmap_close() to get around to doing it to make progress.
Affected packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian:12 | linux | 5.18.16-1 | DEBIAN-CVE-2022-49607 |
| Debian:13 | linux | 5.18.16-1 | DEBIAN-CVE-2022-49607 |
| Debian:14 | linux | 5.18.16-1 | DEBIAN-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux | 5.15.0-50.56 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-allwinner-5.19 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-aws | 5.15.0-1021.25 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-aws-5.19 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-aws-6.2 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-aws-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-azure | 5.15.0-1021.26 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-azure-5.19 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-azure-6.2 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-azure-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-azure-fde | 5.15.0-1024.30.1 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-azure-fde-5.19 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-azure-fde-6.2 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-gcp | 5.15.0-1019.25 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-gcp-5.19 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-gcp-6.2 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-gcp-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-gke | 5.15.0-1017.20 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-gkeop | 5.15.0-1004.6 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-hwe-5.19 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-hwe-6.2 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-hwe-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-ibm | 5.15.0-1015.17 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-intel-iot-realtime | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-intel-iotg | 5.15.0-1017.22 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-kvm | 5.15.0-1019.23 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-lowlatency | 5.15.0-50.56 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-5.19 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.2 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-nvidia | 5.15.0-1015.15 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-nvidia-6.2 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-nvidia-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-oem-5.17 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-oem-6.0 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-oem-6.1 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-oem-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-oracle | 5.15.0-1019.24 | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-oracle-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-raspi | 5.15.0-1016.18 | UBUNTU-CVE-2022-49607 |
| Ubuntu:24.04:LTS | linux-raspi-realtime | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-realtime | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-riscv | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-riscv-5.19 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-riscv-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-starfive-5.19 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-starfive-6.2 | no fix listed | UBUNTU-CVE-2022-49607 |
| Ubuntu:22.04:LTS | linux-starfive-6.5 | no fix listed | UBUNTU-CVE-2022-49607 |
Affected products (as reported)
| Vendor | Product | Versions |
|---|---|---|
| Linux | Linux | 9bb5d40cd93c9dd4be74834b1dcb1ba03629716b – before 3bbd868099287ff9027db59029b502fcfa2202a09bb5d40cd93c9dd4be74834b1dcb1ba03629716b – before f836f9ac95df15f1e0af4beb0ec20021e8c919989bb5d40cd93c9dd4be74834b1dcb1ba03629716b – before 17f5417194136517ee9bbd6511249e5310e5617c9bb5d40cd93c9dd4be74834b1dcb1ba03629716b – before 98c3c8fd0d4c560e0f8335b79c407bbf7fc9462c9bb5d40cd93c9dd4be74834b1dcb1ba03629716b – before 43128b3eee337824158f34da6648163d2f2fb9379bb5d40cd93c9dd4be74834b1dcb1ba03629716b – before da3c256e2d0ebc87c7db0c605c9692b6f17220749bb5d40cd93c9dd4be74834b1dcb1ba03629716b – before a9391ff7a7c5f113d6f2bf6621d49110950de49c9bb5d40cd93c9dd4be74834b1dcb1ba03629716b – before 68e3c69803dada336893640110cb87221bb01dcf |
| Linux | Linux | 3.10 |
Weakness: CWE-362 · Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H
References
- https://git.kernel.org/stable/c/3bbd868099287ff9027db59029b502fcfa2202a0
- https://git.kernel.org/stable/c/f836f9ac95df15f1e0af4beb0ec20021e8c91998
- https://git.kernel.org/stable/c/17f5417194136517ee9bbd6511249e5310e5617c
- https://git.kernel.org/stable/c/98c3c8fd0d4c560e0f8335b79c407bbf7fc9462c
- https://git.kernel.org/stable/c/43128b3eee337824158f34da6648163d2f2fb937
- https://git.kernel.org/stable/c/da3c256e2d0ebc87c7db0c605c9692b6f1722074
- https://git.kernel.org/stable/c/a9391ff7a7c5f113d6f2bf6621d49110950de49c
- https://git.kernel.org/stable/c/68e3c69803dada336893640110cb87221bb01dcf