Skip to content
Heist/ feed
Back to feed
HighFix available

bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel

Type: advisorySources: OSV

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.

Products
Kernel
Affected versions
Not specified
Fixed versions
5.15.150, 6.1.80, 6.6.19, 6.7.7
CVEs
CVE-2024-26737
Confirmed fixed CVEs
Not specified
Updated in this feed
3 Nov 2026, 15:42 UTC · Revision 1

Source evidence

bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel

core-osv · Original source

Published 3 Apr 2024, 17:00 UTC

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.

osv:CVE-2024-26737

Kernel

Fixed versions: 5.15.150, 6.1.80, 6.6.19, 6.7.7

Complete source record
{
  "id": "6f84b148f1bb1ad540b52252d2ab42278115e4cc685d2aab18ea858627d45183",
  "url": "https://osv.dev/vulnerability/CVE-2024-26737",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel",
    "summary": "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.",
    "evidence": "osv:CVE-2024-26737",
    "products": [
      {
        "name": {
          "value": "Kernel",
          "evidence": "/affected/1/package/name"
        },
        "prerequisites": [],
        "fixed_versions": [
          {
            "value": "5.15.150",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.1.80",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.6.19",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.7.7",
            "evidence": "/affected/1/ranges"
          }
        ],
        "affected_versions": []
      }
    ],
    "severity": "high",
    "structured": {
      "id": "CVE-2024-26737",
      "aliases": [
        "CVE-2024-26737"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
              "type": "GIT",
              "events": [
                {
                  "introduced": "b00628b1c7d595ae5b544e059c27b1f5828314b4"
                },
                {
                  "fixed": "5268bb02107b9eedfdcd51db75b407d10043368c"
                },
                {
                  "fixed": "addf5e297e6cbf5341f9c07720693ca9ba0057b5"
                },
                {
                  "fixed": "8327ed12e8ebc5436bfaa1786c49988894f9c8a6"
                },
                {
                  "fixed": "7d80a9e745fa5b47da3bca001f186c02485c7c33"
                },
                {
                  "fixed": "0281b919e175bb9c3128bd3872ac2903e9436e3f"
                }
              ]
            }
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-26737.json"
          }
        },
        {
          "ranges": [
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "5.15.0"
                },
                {
                  "fixed": "5.15.150"
                }
              ]
            },
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "5.16.0"
                },
                {
                  "fixed": "6.1.80"
                }
              ]
            },
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "6.2.0"
                },
                {
                  "fixed": "6.6.19"
                }
              ]
            },
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "6.7.0"
                },
                {
                  "fixed": "6.7.7"
                }
              ]
            }
          ],
          "package": {
            "name": "Kernel",
            "ecosystem": "Linux"
          },
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-26737.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:30.315936692Z",
      "provider": "osv",
      "references": [
        "https://git.kernel.org/stable/c/0281b919e175bb9c3128bd3872ac2903e9436e3f",
        "https://git.kernel.org/stable/c/5268bb02107b9eedfdcd51db75b407d10043368c",
        "https://git.kernel.org/stable/c/7d80a9e745fa5b47da3bca001f186c02485c7c33",
        "https://git.kernel.org/stable/c/8327ed12e8ebc5436bfaa1786c49988894f9c8a6",
        "https://git.kernel.org/stable/c/addf5e297e6cbf5341f9c07720693ca9ba0057b5",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/26xxx/CVE-2024-26737.json",
        "https://nvd.nist.gov/vuln/detail/CVE-2024-26737",
        "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
      ],
      "provider_metadata": {
        "cna_assigner": "Linux",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/26xxx/CVE-2024-26737.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2024-26737",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 496932,
  "published_at": "2024-04-03T17:00:23.414+00:00"
}