CVE-2025-40123: bpf: Enforce expected_attach_type for tailcall compatibility
In the Linux kernel, the following vulnerability has been resolved:
bpf: Enforce expected_attach_type for tailcall compatibility
Yinhao et al. recently reported:
Our fuzzer tool discovered an uninitialized pointer issue in the
bpf_prog_test_run_xdp() function within the Linux kernel's BPF subsystem.
This leads to a NULL pointer dereference when a BPF program attempts to
deference the txq member of struct xdp_buff object.
The test initializes two programs of BPF_PROG_TYPE_XDP: progA acts as the
entry point for bpf_prog_test_run_xdp() and its expected_attach_type can
neither be of be BPF_XDP_DEVMAP nor BPF_XDP_CPUMAP. progA calls into a slot
of a tailcall map it owns. progB's expected_attach_type must be BPF_XDP_DEVMAP
to pass xdp_is_valid_access() validation. The program returns struct xdp_md's
egress_ifindex, and the latter is only allowed to be accessed under mentioned
expected_attach_type. progB is then inserted into the tailcall which progA
calls.
The underlying issue goes beyond XDP though. Another example are programs
of type BPF_PROG_TYPE_CGROUP_SOCK_ADDR. sock_addr_is_valid_access() as well
as sock_addr_func_proto() have different logic depending on the programs'
expected_attach_type. Similarly, a program attached to BPF_CGROUP_INET4_GETPEERNAME
should not be allowed doing a tailcall into a program which calls bpf_bind()
out of BPF which is only enabled for BPF_CGROUP_INET4_CONNECT.
In short, specifying expected_attach_type allows to open up additional
functionality or restrictions beyond what the basic bpf_prog_type enables.
The use of tailcalls must not violate these constraints. Fix it by enforcing
expected_attach_type in __bpf_prog_map_compatible().
Note that we only enforce this for tailcall maps, but not for BPF devmaps or
cpumaps: There, the programs are invoked through dev_map_bpf_prog_run*() and
cpu_map_bpf_prog_run*() which set up a new environment / context and therefore
these situations are not prone to this issue.
Security readout for executives and security teams
Plain-English summary
A Linux kernel BPF flaw allows incompatible programs to be joined through a tail call, bypassing restrictions tied to their intended attachment context. A local, low-privileged attacker could potentially cause serious confidentiality, integrity, or availability impact. The documented trigger includes a kernel NULL-pointer dereference, but the supplied sources do not establish remote exploitation or code execution.
Executive priority
Prioritize internet-facing multi-user hosts, container platforms, and other systems where untrusted local workloads may interact with BPF. Treat remediation as high priority, while recognizing that the supplied evidence requires local access and does not show active exploitation. Validate vendor backports promptly because the bundle’s affected-version data is not sufficiently clear for version-only decisions.
Technical view
BPF tail-call compatibility checked program type but failed to enforce expected_attach_type. This could let a program execute with access or helpers permitted only in another attachment context, including XDP and cgroup socket-address cases. The fix adds expected_attach_type enforcement to __bpf_prog_map_compatible(). Devmap and cpumap execution paths are explicitly excluded because they establish a new context.
Likely exposure
Exposure is limited to Linux systems running affected kernels where an attacker can locally create or manipulate relevant BPF programs and tail-call maps. The bundle lists several affected releases, but its version representation includes an ambiguous “0” entry and does not clearly express complete ranges. Confirm exposure through distribution-specific kernel advisories and backport records.
Exploitation context
The issue was discovered by fuzzing and has a local, low-complexity, low-privilege CVSS vector with no user interaction. The supplied KEV indicator is false, and no cited source establishes active exploitation. The documented failure is a NULL-pointer dereference; broader impact is reflected by the 7.8 CVSS score, but practical exploitation details remain unconfirmed.
Researcher notes
The central invariant is that tail-call map compatibility must preserve expected_attach_type restrictions, not merely bpf_prog_type compatibility. Examples cover XDP context-sensitive fields and cgroup socket-address helper availability. Devmaps and cpumaps are not considered vulnerable through this path. Sources establish the bug and fix design but do not provide a complete affected-range interpretation or evidence of weaponized exploitation.
Mitigation direction
Upgrade to a vendor-supported kernel containing the expected_attach_type tail-call compatibility fix.
Check distribution advisories for backports rather than relying only on upstream version numbers.
Restrict untrusted local access and BPF program-management capabilities until affected systems are updated.
Follow vendor guidance if immediate kernel replacement is operationally impractical.
Validation and detection
Record each system’s running kernel release and distribution package version.
Verify vendor changelogs or source packages include one of the referenced stable fixes.
Inventory environments allowing local users or workloads to manage BPF programs and tail-call maps.
Confirm the updated kernel is active after reboot, not merely installed.
Use authorized, non-destructive regression testing to confirm incompatible tail calls are rejected.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2025-40123 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
1CVSS vectors
3Timeline events
0ADP providers
6Source links
CVSS vector scores
1 official score
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.