CVE-2025-40123

Source
https://nvd.nist.gov/vuln/detail/CVE-2025-40123
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-40123.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2025-40123
Downstream
Published
2025-11-12T10:23:19.589Z
Modified
2025-11-27T02:32:58.787006Z
Summary
bpf: Enforce expected_attach_type for tailcall compatibility
Details

In the Linux kernel, the following vulnerability has been resolved:

bpf: Enforce expectedattachtype for tailcall compatibility

Yinhao et al. recently reported:

Our fuzzer tool discovered an uninitialized pointer issue in the bpfprogtestrunxdp() 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 BPFPROGTYPEXDP: progA acts as the entry point for bpfprogtestrunxdp() and its expectedattachtype can neither be of be BPFXDPDEVMAP nor BPFXDPCPUMAP. progA calls into a slot of a tailcall map it owns. progB's expectedattachtype must be BPFXDPDEVMAP to pass xdpisvalidaccess() validation. The program returns struct xdpmd's egressifindex, and the latter is only allowed to be accessed under mentioned expectedattachtype. progB is then inserted into the tailcall which progA calls.

The underlying issue goes beyond XDP though. Another example are programs of type BPFPROGTYPECGROUPSOCKADDR. sockaddrisvalidaccess() as well as sockaddrfuncproto() have different logic depending on the programs' expectedattachtype. Similarly, a program attached to BPFCGROUPINET4GETPEERNAME should not be allowed doing a tailcall into a program which calls bpfbind() out of BPF which is only enabled for BPFCGROUPINET4_CONNECT.

In short, specifying expectedattachtype allows to open up additional functionality or restrictions beyond what the basic bpfprogtype enables. The use of tailcalls must not violate these constraints. Fix it by enforcing expectedattachtype in _bpfprogmapcompatible().

Note that we only enforce this for tailcall maps, but not for BPF devmaps or cpumaps: There, the programs are invoked through devmapbpfprogrun() and cpu_map_bpf_prog_run() which set up a new environment / context and therefore these situations are not prone to this issue.

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/blob/cc431b3424123d84bcd7afd4de150b33f117a8ef/cves/2025/40xxx/CVE-2025-40123.json"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
5e43f899b03a3492ce5fc44e8900becb04dae9c0
Fixed
a99de19128aec0913f3d529f529fbbff5edfaff8
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
5e43f899b03a3492ce5fc44e8900becb04dae9c0
Fixed
08cb3dc9d2b44f153d0bcf2cb966e4a94b5d0f32
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
5e43f899b03a3492ce5fc44e8900becb04dae9c0
Fixed
f856c598080ba7ce1252867b8ecd6ad5bdaf9a6a
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
5e43f899b03a3492ce5fc44e8900becb04dae9c0
Fixed
c1ad19b5d8e23123503dcaf2d4342e1b90b923ad
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
5e43f899b03a3492ce5fc44e8900becb04dae9c0
Fixed
4540aed51b12bc13364149bf95f6ecef013197c0

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.17.0
Fixed
6.1.156
Type
ECOSYSTEM
Events
Introduced
6.2.0
Fixed
6.6.112
Type
ECOSYSTEM
Events
Introduced
6.7.0
Fixed
6.12.53
Type
ECOSYSTEM
Events
Introduced
6.13.0
Fixed
6.17.3