CVE-2024-35860
JSON

7.8high

bpf: support deferring bpf_link dealloc to after RCU grace period

Severity
7.8high CVSS:3.1 by Linux
Exploit likelihood
0.33% (higher than 18% of CVEs)
Published
Last changed
Assigned by
Linux

Description

In the Linux kernel, the following vulnerability has been resolved: bpf: support deferring bpf_link dealloc to after RCU grace period BPF link for some program types is passed as a "context" which can be used by those BPF programs to look up additional information. E.g., for multi-kprobes and multi-uprobes, link is used to fetch BPF cookie values. Because of this runtime dependency, when bpf_link refcnt drops to zero there could still be active BPF programs running accessing link data. This patch adds generic support to defer bpf_link dealloc callback to after RCU GP, if requested. This is done by exposing two different deallocation callbacks, one synchronous and one deferred. If deferred one is provided, bpf_link_free() will schedule dealloc_deferred() callback to happen after RCU GP. BPF is using two flavors of RCU: "classic" non-sleepable one and RCU tasks trace one. The latter is used when sleepable BPF programs are used. bpf_link_free() accommodates that by checking underlying BPF program's sleepable flag, and goes either through normal RCU GP only for non-sleepable, or through RCU tasks trace GP *and* then normal RCU GP (taking into account rcu_trace_implies_rcu_gp() optimization), if BPF program is sleepable. We use this for multi-kprobe and multi-uprobe links, which dereference link during program run. We also preventively switch raw_tp link to use deferred dealloc callback, as upcoming changes in bpf-next tree expose raw_tp link data (specifically, cookie value) to BPF program at runtime as well.

Affected

Product or packageVersionsReported by
Linux Linuxfrom 0dcac272540613d41c05e89679e4ddb978b612f1 before ac48dc6ac9240f73bf08d29edf65c2deca93ee5d, from 0dcac272540613d41c05e89679e4ddb978b612f1 before 876941f533e7b47fc69977fc4551c02f2d18af97, from 0dcac272540613d41c05e89679e4ddb978b612f1 before 5d8d447777564b35f67000e7838e7ccb64d525c8, from 0dcac272540613d41c05e89679e4ddb978b612f1 before 1a80dbcb2dbaf6e4c216e62e30fa7d3daa8001ce, 5.18
Not affected: before 5.18, from 6.1.191 up to 6.1.*, from 6.6.26 up to 6.6.*, from 6.8.5 up to 6.8.*, from 6.9 up to *
CVE List
linux linux_kernelfrom 5.18 before 6.6.26, from 6.7 before 6.8.5, 6.9NVD

All scores

Linux7.8high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
NVD5.5medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Classification

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

What each source says

CVE List

In the Linux kernel, the following vulnerability has been resolved: bpf: support deferring bpf_link dealloc to after RCU grace period BPF link for some program types is passed as a "context" which can be used by those BPF programs to look up additional information. E.g., for multi-kprobes and multi-uprobes, link is used to fetch BPF cookie values. Because of this runtime dependency, when bpf_link refcnt drops to zero there could still be active BPF programs running accessing link data. This patch adds generic support to defer bpf_link dealloc callback to after RCU GP, if requested. This is done by exposing two different deallocation callbacks, one synchronous and one deferred. If deferred one is provided, bpf_link_free() will schedule dealloc_deferred() callback to happen after RCU GP. BPF is using two flavors of RCU: "classic" non-sleepable one and RCU tasks trace one. The latter is used when sleepable BPF programs are used. bpf_link_free() accommodates that by checking underlying BPF program's sleepable flag, and goes either through normal RCU GP only for non-sleepable, or through RCU tasks trace GP *and* then normal RCU GP (taking into account rcu_trace_implies_rcu_gp() optimization), if BPF program is sleepable. We use this for multi-kprobe and multi-uprobe links, which dereference link during program run. We also preventively switch raw_tp link to use deferred dealloc callback, as upcoming changes in bpf-next tree expose raw_tp link data (specifically, cookie value) to BPF program at runtime as well.

NVD (es)

En el kernel de Linux, se resolvió la siguiente vulnerabilidad: bpf: se admite el aplazamiento de la asignación de bpf_link después del período de gracia de RCU. El enlace BPF para algunos tipos de programas se pasa como un "contexto" que pueden utilizar esos programas BPF para buscar información adicional. Por ejemplo, para multi-kprobes y multi-uprobes, el enlace se utiliza para recuperar valores de cookies BPF. Debido a esta dependencia del tiempo de ejecución, cuando bpf_link refcnt cae a cero, todavía podría haber programas BPF activos ejecutándose y accediendo a los datos del enlace. Este parche agrega soporte genérico para diferir la devolución de llamada de bpf_link dealloc después de RCU GP, si se solicita. Esto se hace exponiendo dos devoluciones de llamada de desasignación diferentes, una sincrónica y otra diferida. Si se proporciona uno diferido, bpf_link_free() programará la devolución de llamada de dealloc_deferred() para que se realice después de RCU GP. BPF utiliza dos tipos de RCU: uno "clásico" que no se puede dormir y uno de seguimiento de tareas de RCU. Este último se utiliza cuando se utilizan programas BPF que se pueden dormir. bpf_link_free() se adapta a eso al verificar el indicador de suspensión del programa BPF subyacente, y pasa por la GP de RCU normal solo para los no dormidos, o a través de tareas de RCU rastrean la GP *y* luego la GP de RCU normal (teniendo en cuenta la optimización de rcu_trace_implies_rcu_gp()), si El programa BPF se puede dormir. Usamos esto para enlaces multi-kprobe y multi-uprobe, que desreferencian el enlace durante la ejecución del programa. También cambiamos preventivamente el enlace raw_tp para usar la devolución de llamada de dealloc diferida, ya que los próximos cambios en el árbol bpf-next también exponen los datos del enlace raw_tp (específicamente, el valor de la cookie) al programa BPF en tiempo de ejecución.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-35860 changed 2026-10-30CVE Terms of Use
NVDCVE-2024-35860 changed 2026-10-30Public domain