{
  "schema_version": "1.6.1",
  "id": "RPI-CVE-2024-40909",
  "modified": "2026-10-09T11:39:44Z",
  "upstream": [
    "CVE-2024-40909"
  ],
  "published": "2024-07-12T12:21:19Z",
  "summary": "bpf: Fix a potential use-after-free in bpf_link_free()",
  "details": "In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix a potential use-after-free in bpf_link_free()\n\nAfter commit 1a80dbcb2dba, bpf_link can be freed by\nlink->ops->dealloc_deferred, but the code still tests and uses\nlink->ops->dealloc afterward, which leads to a use-after-free as\nreported by syzbot. Actually, one of them should be sufficient, so\njust call one of them instead of both. Also add a WARN_ON() in case\nof any problematic implementation.",
  "severity": [
    {
      "type": "CVSS_V3",
      "score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
    }
  ],
  "affected": [
    {
      "package": {
        "ecosystem": "Raspberry Pi OS:12",
        "name": "linux"
      },
      "versions": [
        "1:6.6.28-1+rpt1",
        "1:6.6.31-1+rpt1"
      ],
      "ecosystem_specific": {
        "binaries": [
          {
            "binary_name": "linux-image-6.6.28+rpt-rpi-2712",
            "binary_version": "1:6.6.28-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.6.28+rpt-rpi-v6",
            "binary_version": "1:6.6.28-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.6.28+rpt-rpi-v7",
            "binary_version": "1:6.6.28-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.6.28+rpt-rpi-v7l",
            "binary_version": "1:6.6.28-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.6.28+rpt-rpi-v8",
            "binary_version": "1:6.6.28-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.6.31+rpt-rpi-2712",
            "binary_version": "1:6.6.31-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.6.31+rpt-rpi-v6",
            "binary_version": "1:6.6.31-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.6.31+rpt-rpi-v7",
            "binary_version": "1:6.6.31-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.6.31+rpt-rpi-v7l",
            "binary_version": "1:6.6.31-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.6.31+rpt-rpi-v8",
            "binary_version": "1:6.6.31-1+rpt1"
          }
        ]
      },
      "database_specific": {
        "per_version": {
          "1:6.6.28-1+rpt1": {
            "linux_commit": "0c341f47adc3578cd5f817aa20ee2b7f9ae6b23e",
            "upstream_version": "6.6.28",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.6.35"
          },
          "1:6.6.31-1+rpt1": {
            "linux_commit": "c1432b4bae5b6582f4d32ba381459f33c34d1424",
            "upstream_version": "6.6.31",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.6.35"
          }
        }
      }
    }
  ],
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://www.cve.org/CVERecord?id=CVE-2024-40909"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/91cff53136daeff50816b0baeafd38a6976f6209"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/fa97b8fed9896f1e89cb657513e483a152d4c382"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/2884dc7d08d98a89d8d65121524bb7533183a63a"
    }
  ],
  "database_specific": {
    "source": "https://git.kernel.org/pub/scm/linux/security/vulns.git",
    "upstream_modified": "2026-08-05T11:52:36Z",
    "severity": {
      "source": "kernel CNA",
      "cvss_v3_score": 7.8,
      "cvss_v3_severity": "High",
      "scenario": "AV:L - The vulnerability is reached exclusively through the local `bpf()` syscall \u2014 creating a raw_tracepoint/kprobe_multi/uprobe_multi link and then closing its file descriptor. No network or remote-peer data is involved.\nAC:L - The attacker drives the free side directly and can repeat the create/close cycle in an unbounded loop across all CPUs while generating scheduling and RCU load to force preemption between `call_rcu()` and the stale `link->ops` read; syzbot triggered it in practice, so the window is reachable without relying on conditions outside attacker influence.\nPR:L - `bpf_token_capable()` grants BPF/PERFMON at `ns_capable()` level when a BPF token is delegated (kernel/bpf/token.c:17-28), so a process unprivileged in the init namespace inside a container can load these tracing programs and create the affected links; the same path is reachable by ordinary non-root service accounts holding only CAP_BPF+CAP_PERFMON, which is not administrative control of the host.\nUI:N - The entire sequence \u2014 link creation and fd close \u2014 is performed by the attacker's own process with no action required from any other user.\nS:U - The corruption and its consequences are confined to the kernel's own memory and privilege domain; no hypervisor, IOMMU, or other security-authority boundary is crossed.\nC:H - The use-after-free reads the `ops` pointer out of a freed slab object that the attacker can reallocate and fill via heap spraying, yielding an arbitrary kernel pointer dereference and an arbitrary-read primitive over kernel memory.\nI:H - After the stale `link->ops` read, the code performs `link->ops->dealloc(link)` \u2014 an indirect call through an attacker-controlled function pointer table, giving control-flow hijack and full kernel-integrity compromise.\nA:H - Even unweaponized, dereferencing and calling through a freed/recycled `ops` pointer produces a wild indirect branch and immediate kernel oops or panic, and the attacker can trigger it repeatedly."
    }
  }
}
