CVE-2026-139176: bpf: Fix bpf_timer callback running on a freed map

Published Nov 30, 2026
·
Updated

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

bpf: Fix bpftimer callback running on a freed map

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

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

When user space closes the map, its timers are cancelled and their callbacks are cleared. Since commit 1bfbc267ec91 ("bpf: Enable bpftimer and bpfwq in any context"), bpftimersetcallback() and bpftimerstart() 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 ------ ------ ------ bpftimerstart() finds the timer bpftimersetcallback() finds the timer close(mapfd) 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 bpftimercb() 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 bpfasynccancelandfree() before the map can be freed, and make the bpftimer and bpfwq 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.

Affected Software

1 affected component
Linux Linux kernel

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Compensating control

    In bpf_async_cancel_and_free(), clear the timer’s map pointer before freeing the map so bpf_timer and bpf_wq callbacks return early when it is NULL.

Event History

Nov 30, 2026
CVE Published
via MITRE·01:32 PM
Data Sourced
via MITRE·01:32 PM
Description

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203