// For flags

CVE-2024-26737

bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel

Severity Score

5.5
*CVSS v3.1

Exploit Likelihood

*EPSS

Affected Versions

*CPE

Public Exploits

0
*Multiple Sources

Exploited in Wild

-
*KEV

Decision

Track
*SSVC
Descriptions

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

bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel

The following race is possible between bpf_timer_cancel_and_free
and bpf_timer_cancel. It will lead a UAF on the timer->timer.

bpf_timer_cancel();
spin_lock();
t = timer->time;
spin_unlock();

bpf_timer_cancel_and_free();
spin_lock();
t = timer->timer;
timer->timer = NULL;
spin_unlock();
hrtimer_cancel(&t->timer);
kfree(t);

/* UAF on t */
hrtimer_cancel(&t->timer);

In bpf_timer_cancel_and_free, this patch frees the timer->timer
after a rcu grace period. This requires a rcu_head addition
to the "struct bpf_hrtimer". Another kfree(t) happens in bpf_timer_init,
this does not need a kfree_rcu because it is still under the
spin_lock and timer->timer has not been visible by others yet.

In bpf_timer_cancel, rcu_read_lock() is added because this helper
can be used in a non rcu critical section context (e.g. from
a sleepable bpf prog). Other timer->timer usages in helpers.c
have been audited, bpf_timer_cancel() is the only place where
timer->timer is used outside of the spin_lock.

Another solution considered is to mark a t->flag in bpf_timer_cancel
and clear it after hrtimer_cancel() is done. In bpf_timer_cancel_and_free,
it busy waits for the flag to be cleared before kfree(t). This patch
goes with a straight forward solution and frees timer->timer after
a rcu grace period.

En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: bpf: Corrección de ejecucións entre bpf_timer_cancel_and_free y bpf_timer_cancel La siguiente ejecución es posible entre bpf_timer_cancel_and_free y bpf_timer_cancel. Dirigirá una UAF en el temporizador->temporizador. bpf_timer_cancel(); spin_lock(); t = temporizador->tiempo; spin_unlock(); bpf_timer_cancel_and_free(); spin_lock(); t = temporizador->temporizador; temporizador->temporizador = NULL; spin_unlock(); hrtimer_cancel(&t->temporizador); klibre(t); /* UAF en t */ hrtimer_cancel(&t->timer); En bpf_timer_cancel_and_free, este parche libera el temporizador->temporizador después de un período de gracia de rcu. Esto requiere una adición de rcu_head a "struct bpf_hrtimer". Otro kfree(t) ocurre en bpf_timer_init, esto no necesita un kfree_rcu porque todavía está bajo spin_lock y otros aún no han visible el temporizador->temporizador. En bpf_timer_cancel, se agrega rcu_read_lock() porque este asistente puede usarse en un contexto de sección no crítica para rcu (por ejemplo, desde un programa bpf que se puede dormir). Se han auditado otros usos de temporizador->temporizador en helpers.c, bpf_timer_cancel() es el único lugar donde se usa temporizador->temporizador fuera de spin_lock. Otra solución considerada es marcar una bandera t-> en bpf_timer_cancel y borrarla una vez finalizado hrtimer_cancel(). En bpf_timer_cancel_and_free, está ocupado esperando a que se borre la bandera antes de kfree(t). Este parche incluye una solución sencilla y libera el temporizador->temporizador después de un período de gracia de rcu.

A use-after-free flaw was found in the Linux kernel’s BPF functionality. This flaw allows a local user to crash the system.

*Credits: N/A
CVSS Scores
Attack Vector
Local
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High
* Common Vulnerability Scoring System
SSVC
  • Decision:Track
Exploitation
None
Automatable
No
Tech. Impact
Partial
* Organization's Worst-case Scenario
Timeline
  • 2024-02-19 CVE Reserved
  • 2024-04-03 CVE Published
  • 2024-04-04 EPSS Updated
  • 2024-08-02 CVE Updated
  • ---------- Exploited in Wild
  • ---------- KEV Due Date
  • ---------- First Exploit
CWE
  • CWE-416: Use After Free
CAPEC
Affected Vendors, Products, and Versions
Vendor Product Version Other Status
Vendor Product Version Other Status <-- --> Vendor Product Version Other Status
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 5.15 < 5.15.150
Search vendor "Linux" for product "Linux Kernel" and version " >= 5.15 < 5.15.150"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 5.15 < 6.1.80
Search vendor "Linux" for product "Linux Kernel" and version " >= 5.15 < 6.1.80"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 5.15 < 6.6.19
Search vendor "Linux" for product "Linux Kernel" and version " >= 5.15 < 6.6.19"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 5.15 < 6.7.7
Search vendor "Linux" for product "Linux Kernel" and version " >= 5.15 < 6.7.7"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 5.15 < 6.8
Search vendor "Linux" for product "Linux Kernel" and version " >= 5.15 < 6.8"
en
Affected