{"id":"CVE-2025-40123","aliases":["CVE-2025-40123"],"related":[],"kind":"vulnerability","state":"published","title":"bpf: Enforce expected_attach_type for tailcall compatibility","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Enforce expected_attach_type for tailcall compatibility\n\nYinhao et al. recently reported:\n\n  Our fuzzer tool discovered an uninitialized pointer issue in the\n  bpf_prog_test_run_xdp() function within the Linux kernel's BPF subsystem.\n  This leads to a NULL pointer dereference when a BPF program attempts to\n  deference the txq member of struct xdp_buff object.\n\nThe test initializes two programs of BPF_PROG_TYPE_XDP: progA acts as the\nentry point for bpf_prog_test_run_xdp() and its expected_attach_type can\nneither be of be BPF_XDP_DEVMAP nor BPF_XDP_CPUMAP. progA calls into a slot\nof a tailcall map it owns. progB's expected_attach_type must be BPF_XDP_DEVMAP\nto pass xdp_is_valid_access() validation. The program returns struct xdp_md's\negress_ifindex, and the latter is only allowed to be accessed under mentioned\nexpected_attach_type. progB is then inserted into the tailcall which progA\ncalls.\n\nThe underlying issue goes beyond XDP though. Another example are programs\nof type BPF_PROG_TYPE_CGROUP_SOCK_ADDR. sock_addr_is_valid_access() as well\nas sock_addr_func_proto() have different logic depending on the programs'\nexpected_attach_type. Similarly, a program attached to BPF_CGROUP_INET4_GETPEERNAME\nshould not be allowed doing a tailcall into a program which calls bpf_bind()\nout of BPF which is only enabled for BPF_CGROUP_INET4_CONNECT.\n\nIn short, specifying expected_attach_type allows to open up additional\nfunctionality or restrictions beyond what the basic bpf_prog_type enables.\nThe use of tailcalls must not violate these constraints. Fix it by enforcing\nexpected_attach_type in __bpf_prog_map_compatible().\n\nNote that we only enforce this for tailcall maps, but not for BPF devmaps or\ncpumaps: There, the programs are invoked through dev_map_bpf_prog_run*() and\ncpu_map_bpf_prog_run*() which set up a new environment / context and therefore\nthese situations are not prone to this issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Enforce expected_attach_type for tailcall compatibility\n\nYinhao et al. recently reported:\n\n  Our fuzzer tool discovered an uninitialized pointer issue in the\n  bpf_prog_test_run_xdp() function within the Linux kernel's BPF subsystem.\n  This leads to a NULL pointer dereference when a BPF program attempts to\n  deference the txq member of struct xdp_buff object.\n\nThe test initializes two programs of BPF_PROG_TYPE_XDP: progA acts as the\nentry point for bpf_prog_test_run_xdp() and its expected_attach_type can\nneither be of be BPF_XDP_DEVMAP nor BPF_XDP_CPUMAP. progA calls into a slot\nof a tailcall map it owns. progB's expected_attach_type must be BPF_XDP_DEVMAP\nto pass xdp_is_valid_access() validation. The program returns struct xdp_md's\negress_ifindex, and the latter is only allowed to be accessed under mentioned\nexpected_attach_type. progB is then inserted into the tailcall which progA\ncalls.\n\nThe underlying issue goes beyond XDP though. Another example are programs\nof type BPF_PROG_TYPE_CGROUP_SOCK_ADDR. sock_addr_is_valid_access() as well\nas sock_addr_func_proto() have different logic depending on the programs'\nexpected_attach_type. Similarly, a program attached to BPF_CGROUP_INET4_GETPEERNAME\nshould not be allowed doing a tailcall into a program which calls bpf_bind()\nout of BPF which is only enabled for BPF_CGROUP_INET4_CONNECT.\n\nIn short, specifying expected_attach_type allows to open up additional\nfunctionality or restrictions beyond what the basic bpf_prog_type enables.\nThe use of tailcalls must not violate these constraints. Fix it by enforcing\nexpected_attach_type in __bpf_prog_map_compatible().\n\nNote that we only enforce this for tailcall maps, but not for BPF devmaps or\ncpumaps: There, the programs are invoked through dev_map_bpf_prog_run*() and\ncpu_map_bpf_prog_run*() which set up a new environment / context and therefore\nthese situations are not prone to this issue.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nbpf: Hacer cumplir expected_attach_type para la compatibilidad de tailcall\n\nYinhao et al. informaron recientemente:\n\n  Nuestra herramienta de fuzzing descubrió un problema de puntero no\n  inicializado en la función bpf_prog_test_run_xdp() dentro del subsistema\n  BPF del kernel de Linux. Esto lleva a una desreferencia de puntero NULL\n  cuando un programa BPF intenta desreferenciar el miembro txq del objeto\n  struct xdp_buff.\n\nLa prueba inicializa dos programas de BPF_PROG_TYPE_XDP: progA actúa como\npunto de entrada para bpf_prog_test_run_xdp() y su expected_attach_type no\npuede ser ni BPF_XDP_DEVMAP ni BPF_XDP_CPUMAP. progA llama a una ranura de\nun mapa de tailcall que posee. El expected_attach_type de progB debe ser\nBPF_XDP_DEVMAP para pasar la validación de xdp_is_valid_access(). El\nprograma devuelve el egress_ifindex de struct xdp_md, y este último solo\npuede ser accedido bajo el expected_attach_type mencionado. progB se inserta\nentonces en el tailcall al que llama progA.\n\nSin embargo, el problema subyacente va más allá de XDP. Otro ejemplo son los\nprogramas de tipo BPF_PROG_TYPE_CGROUP_SOCK_ADDR. sock_addr_is_valid_access()\nasí como sock_addr_func_proto() tienen lógica diferente dependiendo del\nexpected_attach_type de los programas. De manera similar, un programa\nadjunto a BPF_CGROUP_INET4_GETPEERNAME no debería permitírsele hacer un\ntailcall a un programa que llama a bpf_bind() fuera de BPF, lo cual solo\nestá habilitado para BPF_CGROUP_INET4_CONNECT.\n\nEn resumen, especificar expected_attach_type permite habilitar funcionalidad\no restricciones adicionales más allá de lo que permite el bpf_prog_type\nbásico. El uso de tailcalls no debe violar estas restricciones. Se soluciona\nhaciendo cumplir expected_attach_type en __bpf_prog_map_compatible().\n\nTenga en cuenta que solo hacemos cumplir esto para los mapas de tailcall,\npero no para los devmaps o cpumaps de BPF: Allí, los programas se invocan a\ntravés de dev_map_bpf_prog_run*() y cpu_map_bpf_prog_run*() que configuran\nun nuevo entorno/contexto y, por lo tanto, estas situaciones no son\npropensas a este problema.","source":"nvd"}],"published":"2025-11-12T10:23:19.589Z","modified":"2026-10-19T21:10:00.160Z","severity":{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"}],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"5e43f899b03a3492ce5fc44e8900becb04dae9c0","fixed":"e53a59e7cee5c1605d1ed595933098c2b69108f9","status":"affected"},{"type":"git","introduced":"5e43f899b03a3492ce5fc44e8900becb04dae9c0","fixed":"dc4f348952173beb8ceb15be30b249276eccb605","status":"affected"},{"type":"git","introduced":"5e43f899b03a3492ce5fc44e8900becb04dae9c0","fixed":"a99de19128aec0913f3d529f529fbbff5edfaff8","status":"affected"},{"type":"git","introduced":"5e43f899b03a3492ce5fc44e8900becb04dae9c0","fixed":"08cb3dc9d2b44f153d0bcf2cb966e4a94b5d0f32","status":"affected"},{"type":"git","introduced":"5e43f899b03a3492ce5fc44e8900becb04dae9c0","fixed":"f856c598080ba7ce1252867b8ecd6ad5bdaf9a6a","status":"affected"},{"type":"git","introduced":"5e43f899b03a3492ce5fc44e8900becb04dae9c0","fixed":"c1ad19b5d8e23123503dcaf2d4342e1b90b923ad","status":"affected"},{"type":"git","introduced":"5e43f899b03a3492ce5fc44e8900becb04dae9c0","fixed":"4540aed51b12bc13364149bf95f6ecef013197c0","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"4.17","status":"affected"},{"type":"semver","introduced":"0","fixed":"4.17","status":"unaffected"},{"type":"semver","introduced":"5.10.270","lastAffected":"5.10.*","status":"unaffected"},{"type":"semver","introduced":"5.15.221","lastAffected":"5.15.*","status":"unaffected"},{"type":"semver","introduced":"6.1.156","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.112","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.53","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.17.3","lastAffected":"6.17.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.18","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"}],"references":[{"url":"https://git.kernel.org/stable/c/e53a59e7cee5c1605d1ed595933098c2b69108f9","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/dc4f348952173beb8ceb15be30b249276eccb605","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/a99de19128aec0913f3d529f529fbbff5edfaff8","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/08cb3dc9d2b44f153d0bcf2cb966e4a94b5d0f32","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/f856c598080ba7ce1252867b8ecd6ad5bdaf9a6a","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/c1ad19b5d8e23123503dcaf2d4342e1b90b923ad","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/4540aed51b12bc13364149bf95f6ecef013197c0","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-10-15T21:57:04.979Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-40123","url":"https://www.cve.org/CVERecord?id=CVE-2025-40123","licence":"CVE Terms of Use","modified":"2026-10-15T22:02:38.256Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-40123","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-40123","licence":"Public domain","modified":"2026-10-19T21:10:00.160Z"}],"updatedAt":"2026-11-25T22:59:07.544Z","epss":{"score":0.00166,"percentile":0.06104,"date":"2026-12-01T12:00:22.000Z"}}