# CVE-2024-41045: bpf: Defer work in bpf_timer_cancel_and_free

- Severity: High 7.8 (CVSS:3.1, scored by Linux) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.30%, higher than 23% of CVEs (2026-12-01)
- Published: 2024-07-29T14:32:02.866Z
- Modified: 2026-10-30T13:17:30.927Z
- Weaknesses: CWE-416
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: Linux

## Description

In the Linux kernel, the following vulnerability has been resolved:

bpf: Defer work in bpf_timer_cancel_and_free

Currently, the same case as previous patch (two timer callbacks trying
to cancel each other) can be invoked through bpf_map_update_elem as
well, or more precisely, freeing map elements containing timers. Since
this relies on hrtimer_cancel as well, it is prone to the same deadlock
situation as the previous patch.

It would be sufficient to use hrtimer_try_to_cancel to fix this problem,
as the timer cannot be enqueued after async_cancel_and_free. Once
async_cancel_and_free has been done, the timer must be reinitialized
before it can be armed again. The callback running in parallel trying to
arm the timer will fail, and freeing bpf_hrtimer without waiting is
sufficient (given kfree_rcu), and bpf_timer_cb will return
HRTIMER_NORESTART, preventing the timer from being rearmed again.

However, there exists a UAF scenario where the callback arms the timer
before entering this function, such that if cancellation fails (due to
timer callback invoking this routine, or the target timer callback
running concurrently). In such a case, if the timer expiration is
significantly far in the future, the RCU grace period expiration
happening before it will free the bpf_hrtimer state and along with it
the struct hrtimer, that is enqueued.

Hence, it is clear cancellation needs to occur after
async_cancel_and_free, and yet it cannot be done inline due to deadlock
issues. We thus modify bpf_timer_cancel_and_free to defer work to the
global workqueue, adding a work_struct alongside rcu_head (both used at
_different_ points of time, so can share space).

Update existing code comments to reflect the new state of affairs.

(As written by CVE List.)

## Affected

- Linux Linux: from b00628b1c7d595ae5b544e059c27b1f5828314b4 before 7b27f15cab4c7d4f28c25b94a5284ad6d9d3695d; from b00628b1c7d595ae5b544e059c27b1f5828314b4 before 5eaa11c500ed07f505f86cec07d5593a71927e26; from b00628b1c7d595ae5b544e059c27b1f5828314b4 before 7aa5a19279c3639ae8b758b63f05d0c616a39fa1; from b00628b1c7d595ae5b544e059c27b1f5828314b4 before a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69; 5.15 (not affected: before 5.15; from 6.1.191 up to 6.1.*; from 6.6.158 up to 6.6.*; from 6.9.10 up to 6.9.*; from 6.10 up to *)
- linux linux_kernel: from 5.15 before 6.9.10; 6.10

## Every score

- Linux: CVSS:3.1 7.8 High `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- NVD: CVSS:3.1 7.8 High `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`

## References

- <https://git.kernel.org/stable/c/7b27f15cab4c7d4f28c25b94a5284ad6d9d3695d>
- <https://git.kernel.org/stable/c/5eaa11c500ed07f505f86cec07d5593a71927e26>
- <https://git.kernel.org/stable/c/7aa5a19279c3639ae8b758b63f05d0c616a39fa1> (patch)
- <https://git.kernel.org/stable/c/a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69> (patch)

## Sources

- CVE List: [CVE-2024-41045](https://www.cve.org/CVERecord?id=CVE-2024-41045), CVE Terms of Use, modified 2026-10-30
- NVD: [CVE-2024-41045](https://nvd.nist.gov/vuln/detail/CVE-2024-41045), Public domain, modified 2026-10-30

---

Page: https://cve.day/CVE-2024-41045 · Whole record: https://cve.day/CVE-2024-41045.json · Rebuilt by cve.day 2026-11-25T22:58:43.301Z
