{"id":"CVE-2026-139176","state":"PUBLISHED","title":"bpf: Fix bpf_timer callback running on a freed map","description":"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.","publishedAt":"2026-11-30T13:32:17.061Z","updatedAt":"2026-11-30T13:32:17.061Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"1bfbc267ec915e58c3723a2237bf067f0c4dffa8","status":"affected","lessThan":"59d581d8e9cc019ebedc8145ec8ba56ca04e2383","versionType":"git"},{"version":"1bfbc267ec915e58c3723a2237bf067f0c4dffa8","status":"affected","lessThan":"815a0a2a40d6c5985a153041231731651bc4024b","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/helpers.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"7.0","status":"affected"},{"version":"0","status":"unaffected","lessThan":"7.0","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/helpers.c"]}],"references":["https://git.kernel.org/stable/c/59d581d8e9cc019ebedc8145ec8ba56ca04e2383","https://git.kernel.org/stable/c/815a0a2a40d6c5985a153041231731651bc4024b"],"weaknesses":[],"ingestedAt":"2026-11-30T13:44:05.999Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139176.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139176","state":"PUBLISHED","datePublished":"2026-11-30T13:32:17.061Z","dateUpdated":"2026-11-30T13:32:17.061Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.918Z"},"containers":{"cna":{"title":"bpf: Fix bpf_timer callback running on a freed map","descriptions":[{"lang":"en","value":"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."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"1bfbc267ec915e58c3723a2237bf067f0c4dffa8","status":"affected","lessThan":"59d581d8e9cc019ebedc8145ec8ba56ca04e2383","versionType":"git"},{"version":"1bfbc267ec915e58c3723a2237bf067f0c4dffa8","status":"affected","lessThan":"815a0a2a40d6c5985a153041231731651bc4024b","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/helpers.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"7.0","status":"affected"},{"version":"0","status":"unaffected","lessThan":"7.0","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/helpers.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/59d581d8e9cc019ebedc8145ec8ba56ca04e2383"},{"url":"https://git.kernel.org/stable/c/815a0a2a40d6c5985a153041231731651bc4024b"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:32:17.061Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"7.0","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"7.0","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}