# CVE-2024-42239: bpf: Fail bpf\_timer\_cancel when callback is being cancelled

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.17% (percentile 6, 2026-12-05)
- **CWE:** CWE-667
- **Published:** 2024-08-07T15:14:27.382Z
- **Modified:** 2026-10-30T13:17:32.660Z

## Who should check

- Anyone running Linux \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 82f2348592ef16c90a55b783c3a1354bcd6d4d1d; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 9369830518688ecd5b08ffc08ab3302ce2b5d0f7; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 3e4e8178a8666c56813bd167b848fca0f4c9af0a; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< d4523831f07a267a943f0dde844bf8ead7495f13
- Anyone running Linux 5.15

## 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 and fixed versions

- Linux: \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 82f2348592ef16c90a55b783c3a1354bcd6d4d1d; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 9369830518688ecd5b08ffc08ab3302ce2b5d0f7; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 3e4e8178a8666c56813bd167b848fca0f4c9af0a; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< d4523831f07a267a943f0dde844bf8ead7495f13 (cvelist)
- Linux: 5.15 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2024-42239. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-42239.md
Affected: Linux >= b00628b1c7d595ae5b544e059c27b1f5828314b4, < 82f2348592ef16c90a55b783c3a1354bcd6d4d1d; >= b00628b1c7d595ae5b544e059c27b1f5828314b4, < 9369830518688ecd5b08ffc08ab3302ce2b5d0f7; >= b00628b1c7d595ae5b544e059c27b1f5828314b4, < 3e4e8178a8666c56813bd167b848fca0f4c9af0a; >= b00628b1c7d595ae5b544e0…
Fixed in: Linux 82f2348592ef16c90a55b783c3a1354bcd6d4d1d, Linux 9369830518688ecd5b08ffc08ab3302ce2b5d0f7, Linux 3e4e8178a8666c56813bd167b848fca0f4c9af0a

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2024-42239 being exploited?

There is no confirmed exploitation: CVE-2024-42239 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.17% chance of exploitation in the next 30 days (as of 2026-12-05).

### How serious is CVE-2024-42239?

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2024-42239?

Linux \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 82f2348592ef16c90a55b783c3a1354bcd6d4d1d; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 9369830518688ecd5b08ffc08ab3302ce2b5d0f7; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< 3e4e8178a8666c56813bd167b848fca0f4c9af0a; \>= b00628b1c7d595ae5b544e059c27b1f5828314b4, \< d4523831f07a267a943f0dde844bf8ead7495f13; Linux 5.15.

### Is there a fix for CVE-2024-42239?

Yes. Fixed in Linux 82f2348592ef16c90a55b783c3a1354bcd6d4d1d, Linux 9369830518688ecd5b08ffc08ab3302ce2b5d0f7, Linux 3e4e8178a8666c56813bd167b848fca0f4c9af0a. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2024-42239?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/9369830518688ecd5b08ffc08ab3302ce2b5d0f7>
- patch: <https://git.kernel.org/stable/c/3e4e8178a8666c56813bd167b848fca0f4c9af0a>
- patch: <https://git.kernel.org/stable/c/d4523831f07a267a943f0dde844bf8ead7495f13>
- other: <https://git.kernel.org/stable/c/82f2348592ef16c90a55b783c3a1354bcd6d4d1d>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2024-42239>

HTML: <https://flawdb.com/CVE-2024-42239> · JSON: <https://flawdb.com/api/v1/entries/CVE-2024-42239>
