Vulnerability · Published Aug 7, 2024 · Assigned by Linux

CVE-2024-42239bpf: Fail bpf_timer_cancel when callback is being cancelled

Medium 5.5

In plain English

A medium-severity security flaw 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 6% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS NVD)5.5Medium
Exploit odds (30 days)0.2%top 94.1% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official description

In the Linux kernel, the following vulnerability has been resolved: bpf: Fail bpf_timer_cancel when callback is being cancelled Given a schedule: timer1 cb timer2 cb bpf_timer_cancel(timer2); bpf_timer_cancel(timer1); Both bpf_timer_cancel calls would wait for the other callback to finish executing, introducing a lockup. Add an atomic_t count named 'cancelling' in bpf_hrtimer. This keeps track of all in-flight cancellation requests for a given BPF timer. Whenever cancelling a BPF timer, we must check if we have outstanding cancellation requests, and if so, we must fail the operation with an error (-EDEADLK) since cancellation is synchronous and waits for the callback to finish executing. This implies that we can enter a deadlock situation involving two or more timer callbacks executing in parallel and attempting to cancel one another. Note that we avoid incrementing the cancelling counter for the target timer (the one being cancelled) if bpf_timer_cancel is not invoked from a callback, to avoid spurious errors. The whole point of detecting cur->cancelling and returning -EDEADLK is to not enter a busy wait loop (which may or may not lead to a lockup). This does not apply in case the caller is in a non-callback context, the other side can continue to cancel as it sees fit without running into errors. Background on prior attempts: Earlier versions of this patch used a bool 'cancelling' bit and used the following pattern under timer->lock to publish cancellation status. lock(t->lock); t->cancelling = true; mb(); if (cur->cancelling) return -EDEADLK; unlock(t->lock); hrtimer_cancel(t->timer); t->cancelling = false; The store outside the critical section could overwrite a parallel requests t->cancelling assignment to true, to ensure the parallely executing callback observes its cancellation status. It would be necessary to clear this cancelling bit once hrtimer_cancel is done, but lack of serialization introduced races. Another option was explored where bpf_timer_start would clear the bit when (re)starting the timer under timer->lock. This would ensure serialized access to the cancelling bit, but may allow it to be cleared before in-flight hrtimer_cancel has finished executing, such that lockups can occur again. Thus, we choose an atomic counter to keep track of all outstanding cancellation requests and use it to prevent lockups in case callbacks attempt to cancel each other while executing in parallel.

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:12linuxno fix listedDEBIAN-CVE-2024-42239
Debian:13linux6.9.10-1DEBIAN-CVE-2024-42239
Debian:14linux6.9.10-1DEBIAN-CVE-2024-42239
Ubuntu:22.04:LTSlinuxno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux6.8.0-48.48UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-allwinner-5.19no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-awsno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-aws6.8.0-1018.20UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-aws-5.19no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-aws-6.2no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-aws-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-aws-6.86.8.0-1018.19~22.04.1UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-azureno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-azure6.8.0-1017.20UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-azure-5.19no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-azure-6.2no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-azure-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-azure-6.86.8.0-1017.20~22.04.1UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-azure-fdeno fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-azure-fde-5.19no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-azure-fde-6.2no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-gcpno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-gcp6.8.0-1017.19UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-gcp-5.19no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-gcp-6.2no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-gcp-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-gcp-6.86.8.0-1017.19~22.04.1UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-gkeno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-gke6.8.0-1013.17UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-gkeopno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-gkeop6.8.0-1002.4UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-hwe-5.19no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-hwe-6.2no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-hwe-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-hwe-6.86.8.0-48.48~22.04.1UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-ibmno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-ibm6.8.0-1015.15UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-ibm-6.86.8.0-1015.15~22.04.1UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-intel-iot-realtimeno fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-intel-iotgno fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-kvmno fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-lowlatencyno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-lowlatency6.8.0-48.48.3UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-lowlatency-hwe-5.19no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.2no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.86.8.0-48.48.3~22.04.1UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-nvidiano fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-nvidia6.8.0-1017.19UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-nvidia-6.2no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-nvidia-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-nvidia-6.86.8.0-1017.19~22.04.1UBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-nvidia-lowlatency6.8.0-1017.19.1UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-nvidia-tegrano fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-nvidia-tegra-igxno fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-oem-5.17no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-oem-6.0no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-oem-6.1no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-oem-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-oem-6.86.8.0-1016.16UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-oracleno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-oracle6.8.0-1015.16UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-oracle-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-oracle-6.86.8.0-1015.15~22.04.1UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-raspino fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-raspi6.8.0-1014.16UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-riscv6.8.0-48.48.1UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-riscv-5.19no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-riscv-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-riscv-6.86.8.0-48.48.1~22.04.2UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-starfive-5.19no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-starfive-6.2no fix listedUBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-starfive-6.5no fix listedUBUNTU-CVE-2024-42239
Ubuntu:24.04:LTSlinux-xilinx6.8.0-1009.10UBUNTU-CVE-2024-42239
Ubuntu:22.04:LTSlinux-xilinx-zynqmpno fix listedUBUNTU-CVE-2024-42239

Affected products (as reported)

VendorProductVersions
Linux Linux b00628b1c7d595ae5b544e059c27b1f5828314b4 – before 82f2348592ef16c90a55b783c3a1354bcd6d4d1db00628b1c7d595ae5b544e059c27b1f5828314b4 – before 9369830518688ecd5b08ffc08ab3302ce2b5d0f7b00628b1c7d595ae5b544e059c27b1f5828314b4 – before 3e4e8178a8666c56813bd167b848fca0f4c9af0ab00628b1c7d595ae5b544e059c27b1f5828314b4 – before d4523831f07a267a943f0dde844bf8ead7495f13
Linux Linux 5.15

References