CVE-2026-139176

bpf: Fix bpf_timer callback running on a freed map

Published Nov 30, 2026 CVSS n/a EPSS < 1% KEV · Not listed
Description
In the Linux kernel, the following vulnerability has been resolved:

bpf: Fix bpf_timer callback running on a freed map

A bpf_timer in an inner map can fire after the map has been freed, and
bpf_timer_cb() then reads the freed map:

[ 50.709520] BUG: KASAN: slab-use-after-free in bpf_timer_cb+0x249/0x290
[ 50.709540] Read of size 4 at addr ff11000003bc1030 by task bpftimer/72
...
[ 50.710783] Freed by task 12:
...
[ 50.710826] bpf_map_free+0x1a2/0x380

When user space closes the map, its timers are cancelled and their
callbacks are cleared. Since commit 1bfbc267ec91 ("bpf: Enable
bpf_timer and bpf_wq in any context"), bpf_timer_set_callback() and
bpf_timer_start() run without a lock, so a program that found the timer
just before the close can still use it afterwards:

Task A Task B Task C
------ ------ ------
bpf_timer_start()
finds the timer
bpf_timer_set_callback()
finds the timer
close(map_fd)
clears the callback
cancels the timer
sets the callback
arms the timer
deletes the map from
the outer map
map is freed
the timer fires
bpf_timer_cb() reads the freed map

The timer is cancelled once more when it is finally freed, but that
happens well after the inner map is freed, so a timer started this way
can still fire on the freed map.

Clear the timer's map pointer in bpf_async_cancel_and_free() before the
map can be freed, and make the bpf_timer and bpf_wq callbacks return
early when it is NULL. The map is not freed until callbacks that are
already running have finished, so a callback either sees the map while
it is still valid or sees NULL.

The reproducer below calls the two helpers in a loop on two CPUs while a
third CPU keeps creating an inner map with a timer, closing it and
removing it from the outer map. This bug was identified and confirmed
with the help of a deterministic hypervisor currently under development,
but the non-deterministic C reproducer can typically trigger it in the
1-50s time range. With the fix, nothing is triggered after 600 seconds.

Analysis

AI-generated

Technical impact

The Linux kernel’s eBPF timer subsystem improperly handles timer callbacks after their host map has been freed. When a timer is started on an inner map and the outer map is closed and removed, the timer may fire after the map’s memory has been reclaimed. The callback dereferences a dangling pointer, triggering a KASAN use‑after‑free error and corrupting kernel memory, which can lead to a kernel crash or, if the attacker can control the freed memory contents, potential code execution with elevated privileges.

Affected Systems

The flaw affects all Linux kernel builds that compile the eBPF timer feature as part of the standard bpf subsystem. No specific version bounds are provided, so any kernel prior to the inclusion of the fix (commit 1bfbc267ec91 and its subsequent patch that nulls the timer’s map pointer) is potentially vulnerable. The weakness applies to any distribution or custom build that uses this kernel code.

Risk and Exploitability

The vulnerability requires a local user‑space program that can create eBPF maps and timers. By racing the timer start, callback set and map closure operations, an attacker can exercise the use‑after‑free. No publicly reported exploits are known, and the EPSS score is not available. It is not listed in the CISA KEV catalog. The lack of a public exploit does not negate the severity; the potential for kernel memory corruption and privilege escalation warrants a high risk assessment given the local nature of the attack vector.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade the kernel to a version that incorporates the bpf_timer cleanup fix (any distribution update or source patch that includes commit 1bfbc267ec91 or its subsequent fix).
  • If a kernel upgrade is not immediately possible, modify eBPF programs to avoid creating timers on maps that may be closed concurrently; ensure any timers are cancelled before the map is freed or removed from its container.
  • Enable kernel hardening options such as CONFIG_BPF_JIT, reduce eBPF execution privileges, and consider disabling the bpf_timer subsystem if it is not required for your workloads.

Generated by OpenCVE AI on December 1, 2026 at 21:27 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Weaknesses CWE-416
Type Values Removed Values Added
First Time appeared Linux linux
Vendors & Products Linux linux
Type Values Removed Values Added
Weaknesses CWE-416
Type Values Removed Values Added
Description In the Linux kernel, the following vulnerability has been resolved: bpf: Fix bpf_timer callback running on a freed map A bpf_timer in an inner map can fire after the map has been freed, and bpf_timer_cb() then reads the freed map: [ 50.709520] BUG: KASAN: slab-use-after-free in bpf_timer_cb+0x249/0x290 [ 50.709540] Read of size 4 at addr ff11000003bc1030 by task bpftimer/72 ... [ 50.710783] Freed by task 12: ... [ 50.710826] bpf_map_free+0x1a2/0x380 When user space closes the map, its timers are cancelled and their callbacks are cleared. Since commit 1bfbc267ec91 ("bpf: Enable bpf_timer and bpf_wq in any context"), bpf_timer_set_callback() and bpf_timer_start() run without a lock, so a program that found the timer just before the close can still use it afterwards: Task A Task B Task C ------ ------ ------ bpf_timer_start() finds the timer bpf_timer_set_callback() finds the timer close(map_fd) clears the callback cancels the timer sets the callback arms the timer deletes the map from the outer map map is freed the timer fires bpf_timer_cb() reads the freed map The timer is cancelled once more when it is finally freed, but that happens well after the inner map is freed, so a timer started this way can still fire on the freed map. Clear the timer's map pointer in bpf_async_cancel_and_free() before the map can be freed, and make the bpf_timer and bpf_wq callbacks return early when it is NULL. The map is not freed until callbacks that are already running have finished, so a callback either sees the map while it is still valid or sees NULL. The reproducer below calls the two helpers in a loop on two CPUs while a third CPU keeps creating an inner map with a timer, closing it and removing it from the outer map. This bug was identified and confirmed with the help of a deterministic hypervisor currently under development, but the non-deterministic C reproducer can typically trigger it in the 1-50s time range. With the fix, nothing is triggered after 600 seconds.
Title bpf: Fix bpf_timer callback running on a freed map
First Time appeared Linux
Linux linux Kernel
CPEs cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
Vendors & Products Linux
Linux linux Kernel
References
Weaknesses

No weakness.

Sources

Status
PUBLISHED
Assigner
Linux
Published
Updated
Nov 30, 2026, 1:32 PM
Reserved
Nov 30, 2026, 1:22 PM
Status
Received
Published
Nov 30, 2026, 2:18 PM
Modified
Nov 30, 2026, 2:18 PM