CVE-2024-26737
bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel
Reported by linux · Published April 3, 2024
In the Linux kernel, the following vulnerability has been resolved: bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel The following race is possible between bpf_timer_cancel_and_free and bpf_timer_cancel. It will lead a UAF on the timer->timer. bpf_timer_cancel(); spin_lock(); t = timer->time; spin_unlock(); bpf_timer_cancel_and_free(); spin_lock(); t = timer->timer; timer->timer = NULL; spin_unlock(); hrtimer_cancel(&t->timer); kfree(t); /* UAF on t */ hrtimer_cancel(&t->timer); In bpf_timer_cancel_and_free, this patch frees the timer->timer after a rcu grace period. This requires a rcu_head addition to the "struct bpf_hrtimer". Another kfree(t) happens in bpf_timer_init, this does not need a kfree_rcu because it is still under the spin_lock and timer->timer has not been visible by others yet. In bpf_timer_cancel, rcu_read_lock() is added because this helper can be used in a non rcu critical section context (e.g. from a sleepable bpf prog). Other timer->timer usages in helpers.c have been audited, bpf_timer_cancel() is the only place where timer->timer is used outside of the spin_lock. Another solution considered is to mark a t->flag in bpf_timer_cancel and clear it after hrtimer_cancel() is done. In bpf_timer_cancel_and_free, it busy waits for the flag to be cleared before kfree(t). This patch goes with a straight forward solution and frees timer->timer after a rcu grace period.
Fixed versions
Upgrade to a fixed version or later. Language registries are listed first, then Linux distributions, then vendor products.
| Package | Ecosystem | Fixed in |
|---|---|---|
| kernel-devel | Amazon Linux | 6.1.82-99.168.amzn2023 |
| kernel-livepatch-6.1.82-99.168 | Amazon Linux | 1.0-0.amzn2023 |
Risk scores
Affected products
| Vendor | Product | Versions |
|---|---|---|
| Linux | Linux | b00628b1c7d595ae5b544e059c27b1f5828314b4, b00628b1c7d595ae5b544e059c27b1f5828314b4, b00628b1c7d595ae5b544e059c27b1f5828314b4 |
| Linux | Linux | 5.15, 0, 5.15.150 |
| amazon:2023 | kernel-devel | 0 |
| amazon:2023 | kernel-livepatch-6.1.82-99.168 | 0 |
| Linux | Linux | *, *, 6.6.19 |
| amazon:2023 | python3-perf | 0 |
| amazon:2023 | kernel-libbpf | 0 |
| amazon:2023 | kernel-tools | 0 |
| amazon:2023 | kernel-headers | 0 |
| linux | linux_kernel | 5.15, 5.15, 5.15 |
| amazon:2023 | kernel-modules-extra-common | 0 |
| amazon:2023 | kernel | 0 |
| amazon:2023 | kernel-tools-devel | 0 |
| amazon:2023 | kernel-modules-extra | 0 |
| amazon:2023 | perf | 0 |
| amazon:2023 | kernel-libbpf-static | 0 |
| amazon:2023 | kernel-libbpf-devel | 0 |
| amazon:2023 | bpftool | 0 |
Timeline
- Apr 3, 2024 CVE Published
- Apr 4, 2024 EPSS Score (30 in total, the first dated here)
- Oct 4, 2024 Coalition ESS Score (16 in total, the first dated here)
- Jan 15, 2026 Security Advisory (312 in total, the first dated here)
- Mar 30, 2026 Distribution Patch (272 in total, the first dated here)
- Oct 25, 2026 CVE Updated
Query this with the API
The same record, from the CLI:
vulnetix vdb vuln CVE-2024-26737
vulnetix vdb fixes CVE-2024-26737
Or with curl, using the org id and key from your account page:
curl -s -H "Authorization: ApiKey ${VULNETIX_ORG_ID}:${VULNETIX_API_KEY}" \
"https://api.vdb.vulnetix.com/v2/vuln/CVE-2024-26737/fixes/registry"
The Community plan is free and allows 50 queries a day. Get a free API key · API quickstart