{"id":"CVE-2026-139176","aliases":["CVE-2026-139176"],"related":[],"kind":"vulnerability","state":"published","title":"bpf: Fix bpf_timer callback running on a freed map","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix bpf_timer callback running on a freed map\n\nA bpf_timer in an inner map can fire after the map has been freed, and\nbpf_timer_cb() then reads the freed map:\n\n  [   50.709520] BUG: KASAN: slab-use-after-free in bpf_timer_cb+0x249/0x290\n  [   50.709540] Read of size 4 at addr ff11000003bc1030 by task bpftimer/72\n  ...\n  [   50.710783] Freed by task 12:\n  ...\n  [   50.710826]  bpf_map_free+0x1a2/0x380\n\nWhen user space closes the map, its timers are cancelled and their\ncallbacks are cleared.  Since commit 1bfbc267ec91 (\"bpf: Enable\nbpf_timer and bpf_wq in any context\"), bpf_timer_set_callback() and\nbpf_timer_start() run without a lock, so a program that found the timer\njust before the close can still use it afterwards:\n\n  Task A                  Task B                  Task C\n  ------                  ------                  ------\n  bpf_timer_start()\n    finds the timer\n                          bpf_timer_set_callback()\n                            finds the timer\n                                                  close(map_fd)\n                                                    clears the callback\n                                                    cancels the timer\n                            sets the callback\n    arms the timer\n                                                  deletes the map from\n                                                  the outer map\n                                                    map is freed\n  the timer fires\n    bpf_timer_cb() reads the freed map\n\nThe timer is cancelled once more when it is finally freed, but that\nhappens well after the inner map is freed, so a timer started this way\ncan still fire on the freed map.\n\nClear the timer's map pointer in bpf_async_cancel_and_free() before the\nmap can be freed, and make the bpf_timer and bpf_wq callbacks return\nearly when it is NULL.  The map is not freed until callbacks that are\nalready running have finished, so a callback either sees the map while\nit is still valid or sees NULL.\n\nThe reproducer below calls the two helpers in a loop on two CPUs while a\nthird CPU keeps creating an inner map with a timer, closing it and\nremoving it from the outer map.  This bug was identified and confirmed\nwith the help of a deterministic hypervisor currently under development,\nbut the non-deterministic C reproducer can typically trigger it in the\n1-50s time range.  With the fix, nothing is triggered after 600 seconds.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix bpf_timer callback running on a freed map\n\nA bpf_timer in an inner map can fire after the map has been freed, and\nbpf_timer_cb() then reads the freed map:\n\n  [   50.709520] BUG: KASAN: slab-use-after-free in bpf_timer_cb+0x249/0x290\n  [   50.709540] Read of size 4 at addr ff11000003bc1030 by task bpftimer/72\n  ...\n  [   50.710783] Freed by task 12:\n  ...\n  [   50.710826]  bpf_map_free+0x1a2/0x380\n\nWhen user space closes the map, its timers are cancelled and their\ncallbacks are cleared.  Since commit 1bfbc267ec91 (\"bpf: Enable\nbpf_timer and bpf_wq in any context\"), bpf_timer_set_callback() and\nbpf_timer_start() run without a lock, so a program that found the timer\njust before the close can still use it afterwards:\n\n  Task A                  Task B                  Task C\n  ------                  ------                  ------\n  bpf_timer_start()\n    finds the timer\n                          bpf_timer_set_callback()\n                            finds the timer\n                                                  close(map_fd)\n                                                    clears the callback\n                                                    cancels the timer\n                            sets the callback\n    arms the timer\n                                                  deletes the map from\n                                                  the outer map\n                                                    map is freed\n  the timer fires\n    bpf_timer_cb() reads the freed map\n\nThe timer is cancelled once more when it is finally freed, but that\nhappens well after the inner map is freed, so a timer started this way\ncan still fire on the freed map.\n\nClear the timer's map pointer in bpf_async_cancel_and_free() before the\nmap can be freed, and make the bpf_timer and bpf_wq callbacks return\nearly when it is NULL.  The map is not freed until callbacks that are\nalready running have finished, so a callback either sees the map while\nit is still valid or sees NULL.\n\nThe reproducer below calls the two helpers in a loop on two CPUs while a\nthird CPU keeps creating an inner map with a timer, closing it and\nremoving it from the outer map.  This bug was identified and confirmed\nwith the help of a deterministic hypervisor currently under development,\nbut the non-deterministic C reproducer can typically trigger it in the\n1-50s time range.  With the fix, nothing is triggered after 600 seconds.","source":"cvelist"}],"published":"2026-11-30T13:32:17.061Z","modified":"2026-11-30T14:18:36.653Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"1bfbc267ec915e58c3723a2237bf067f0c4dffa8","fixed":"59d581d8e9cc019ebedc8145ec8ba56ca04e2383","status":"affected"},{"type":"git","introduced":"1bfbc267ec915e58c3723a2237bf067f0c4dffa8","fixed":"815a0a2a40d6c5985a153041231731651bc4024b","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"7.0","status":"affected"},{"type":"semver","introduced":"0","fixed":"7.0","status":"unaffected"},{"type":"semver","introduced":"7.3.6","lastAffected":"7.3.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.4-rc1","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"}],"references":[{"url":"https://git.kernel.org/stable/c/59d581d8e9cc019ebedc8145ec8ba56ca04e2383","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/815a0a2a40d6c5985a153041231731651bc4024b","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-139176","url":"https://www.cve.org/CVERecord?id=CVE-2026-139176","licence":"CVE Terms of Use","modified":"2026-11-30T13:32:17.061Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-139176","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-139176","licence":"Public domain","modified":"2026-11-30T14:18:36.653Z"}],"updatedAt":"2026-11-30T14:32:49.410Z","epss":{"score":0.0019,"percentile":0.09068,"date":"2026-12-01T12:00:22.000Z"}}