CVE-2025-40123
JSON

7.8high

bpf: Enforce expected_attach_type for tailcall compatibility

Severity
7.8high CVSS:3.1 by Linux
Exploit likelihood
0.17% (higher than 6% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
Linux

Description

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.

Affected

Product or packageVersionsReported by
Linux Linuxfrom 5e43f899b03a3492ce5fc44e8900becb04dae9c0 before e53a59e7cee5c1605d1ed595933098c2b69108f9, from 5e43f899b03a3492ce5fc44e8900becb04dae9c0 before dc4f348952173beb8ceb15be30b249276eccb605, from 5e43f899b03a3492ce5fc44e8900becb04dae9c0 before a99de19128aec0913f3d529f529fbbff5edfaff8, from 5e43f899b03a3492ce5fc44e8900becb04dae9c0 before 08cb3dc9d2b44f153d0bcf2cb966e4a94b5d0f32, from 5e43f899b03a3492ce5fc44e8900becb04dae9c0 before f856c598080ba7ce1252867b8ecd6ad5bdaf9a6a, from 5e43f899b03a3492ce5fc44e8900becb04dae9c0 before c1ad19b5d8e23123503dcaf2d4342e1b90b923ad, from 5e43f899b03a3492ce5fc44e8900becb04dae9c0 before 4540aed51b12bc13364149bf95f6ecef013197c0, 4.17
Not affected: before 4.17, from 5.10.270 up to 5.10.*, from 5.15.221 up to 5.15.*, from 6.1.156 up to 6.1.*, from 6.6.112 up to 6.6.*, from 6.12.53 up to 6.12.*
CVE List

Classification

SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.

What each source says

CVE List

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.

NVD (es)

En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta: bpf: Hacer cumplir expected_attach_type para la compatibilidad de tailcall Yinhao et al. informaron recientemente: Nuestra herramienta de fuzzing descubrió un problema de puntero no inicializado en la función bpf_prog_test_run_xdp() dentro del subsistema BPF del kernel de Linux. Esto lleva a una desreferencia de puntero NULL cuando un programa BPF intenta desreferenciar el miembro txq del objeto struct xdp_buff. La prueba inicializa dos programas de BPF_PROG_TYPE_XDP: progA actúa como punto de entrada para bpf_prog_test_run_xdp() y su expected_attach_type no puede ser ni BPF_XDP_DEVMAP ni BPF_XDP_CPUMAP. progA llama a una ranura de un mapa de tailcall que posee. El expected_attach_type de progB debe ser BPF_XDP_DEVMAP para pasar la validación de xdp_is_valid_access(). El programa devuelve el egress_ifindex de struct xdp_md, y este último solo puede ser accedido bajo el expected_attach_type mencionado. progB se inserta entonces en el tailcall al que llama progA. Sin embargo, el problema subyacente va más allá de XDP. Otro ejemplo son los programas de tipo BPF_PROG_TYPE_CGROUP_SOCK_ADDR. sock_addr_is_valid_access() así como sock_addr_func_proto() tienen lógica diferente dependiendo del expected_attach_type de los programas. De manera similar, un programa adjunto a BPF_CGROUP_INET4_GETPEERNAME no debería permitírsele hacer un tailcall a un programa que llama a bpf_bind() fuera de BPF, lo cual solo está habilitado para BPF_CGROUP_INET4_CONNECT. En resumen, especificar expected_attach_type permite habilitar funcionalidad o restricciones adicionales más allá de lo que permite el bpf_prog_type básico. El uso de tailcalls no debe violar estas restricciones. Se soluciona haciendo cumplir expected_attach_type en __bpf_prog_map_compatible(). Tenga en cuenta que solo hacemos cumplir esto para los mapas de tailcall, pero no para los devmaps o cpumaps de BPF: Allí, los programas se invocan a través de dev_map_bpf_prog_run*() y cpu_map_bpf_prog_run*() que configuran un nuevo entorno/contexto y, por lo tanto, estas situaciones no son propensas a este problema.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-40123 changed 2026-10-15CVE Terms of Use
NVDCVE-2025-40123 changed 2026-10-19Public domain