CVE-2024-50164
bpf: Fix overloading of MEM_UNINIT's meaning
Severity Score
Exploit Likelihood
Affected Versions
Public Exploits
0Exploited in Wild
-Decision
Descriptions
In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix overloading of MEM_UNINIT's meaning
Lonial reported an issue in the BPF verifier where check_mem_size_reg()
has the following code:
if (!tnum_is_const(reg->var_off))
/* For unprivileged variable accesses, disable raw
* mode so that the program is required to
* initialize all the memory that the helper could
* just partially fill up.
*/
meta = NULL;
This means that writes are not checked when the register containing the
size of the passed buffer has not a fixed size. Through this bug, a BPF
program can write to a map which is marked as read-only, for example,
.rodata global maps.
The problem is that MEM_UNINIT's initial meaning that "the passed buffer
to the BPF helper does not need to be initialized" which was added back
in commit 435faee1aae9 ("bpf, verifier: add ARG_PTR_TO_RAW_STACK type")
got overloaded over time with "the passed buffer is being written to".
The problem however is that checks such as the above which were added later
via 06c1c049721a ("bpf: allow helpers access to variable memory") set meta
to NULL in order force the user to always initialize the passed buffer to
the helper. Due to the current double meaning of MEM_UNINIT, this bypasses
verifier write checks to the memory (not boundary checks though) and only
assumes the latter memory is read instead.
Fix this by reverting MEM_UNINIT back to its original meaning, and having
MEM_WRITE as an annotation to BPF helpers in order to then trigger the
BPF verifier checks for writing to memory.
Some notes: check_arg_pair_ok() ensures that for ARG_CONST_SIZE{,_OR_ZERO}
we can access fn->arg_type[arg - 1] since it must contain a preceding
ARG_PTR_TO_MEM. For check_mem_reg() the meta argument can be removed
altogether since we do check both BPF_READ and BPF_WRITE. Same for the
equivalent check_kfunc_mem_size_reg().
En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: bpf: Se corrige la sobrecarga del significado de MEM_UNINIT Lonial informó de un problema en el verificador BPF donde check_mem_size_reg() tiene el siguiente código: if (!tnum_is_const(reg->var_off)) /* Para accesos a variables sin privilegios, deshabilitar el modo sin formato * para que el programa deba * inicializar toda la memoria que el ayudante podría * llenar parcialmente. */ meta = NULL; Esto significa que las escrituras no se verifican cuando el registro que contiene el tamaño del búfer pasado no tiene un tamaño fijo. A través de este error, un programa BPF puede escribir en un mapa que está marcado como de solo lectura, por ejemplo, mapas globales .rodata. El problema es que el significado inicial de MEM_UNINIT de que "el buffer pasado al ayudante BPF no necesita ser inicializado" que se agregó en el commit 435faee1aae9 ("bpf, verificador: agregar tipo ARG_PTR_TO_RAW_STACK") se sobrecargó con el tiempo con "se está escribiendo en el búfer pasado". Sin embargo, el problema es que las comprobaciones como la anterior que se agregaron más tarde a través de 06c1c049721a ("bpf: permitir que los ayudantes accedan a la memoria variable") establecen meta en NULL para obligar al usuario a inicializar siempre el búfer pasado al ayudante. Debido al doble significado actual de MEM_UNINIT, esto omite las comprobaciones de escritura del verificador en la memoria (aunque no las comprobaciones de los límites) y solo supone que se lee la última memoria en su lugar. Solucione esto revirtiendo MEM_UNINIT a su significado original y haciendo que MEM_WRITE sea una anotación para los ayudantes de BPF para luego activar las comprobaciones del verificador de BPF para escribir en la memoria. Algunas notas: check_arg_pair_ok() garantiza que para ARG_CONST_SIZE{,_OR_ZERO} podamos acceder a fn->arg_type[arg - 1] ya que debe contener un ARG_PTR_TO_MEM anterior. Para check_mem_reg(), el argumento meta se puede eliminar por completo ya que verificamos tanto BPF_READ como BPF_WRITE. Lo mismo para el check_kfunc_mem_size_reg() equivalente.
CVSS Scores
SSVC
- Decision:-
Timeline
- 2024-10-21 CVE Reserved
- 2024-11-07 CVE Published
- 2024-11-07 CVE Updated
- ---------- EPSS Updated
- ---------- Exploited in Wild
- ---------- KEV Due Date
- ---------- First Exploit
CWE
CAPEC
References (10)
URL | Tag | Source |
---|---|---|
https://git.kernel.org/stable/c/7b3552d3f9f6897851fc453b5131a967167e43c2 | Vuln. Introduced | |
https://git.kernel.org/stable/c/6099a6c8a749a5c8d5f8b4c4342022a92072a02b | Vuln. Introduced | |
https://git.kernel.org/stable/c/bfe25df63048edd4ceaf78a2fc755d5e2befc978 | Vuln. Introduced | |
https://git.kernel.org/stable/c/717c39718dbc4f7ebcbb7b625fb11851cd9007fe | Vuln. Introduced | |
https://git.kernel.org/stable/c/5d0bba8232bf22ce13747cbfc8f696318ff01a50 | Vuln. Introduced | |
https://git.kernel.org/stable/c/70674d11d14eeecad90be4b409a22b902112ba32 | Vuln. Introduced | |
https://git.kernel.org/stable/c/a08d942ecbf46e23a192093f6983cb1d779f4fa8 | Vuln. Introduced |
URL | Date | SRC |
---|
URL | Date | SRC |
---|
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.19 < 6.6.59 Search vendor "Linux" for product "Linux Kernel" and version " >= 5.19 < 6.6.59" | en |
Affected
| ||||||
Linux Search vendor "Linux" | Linux Kernel Search vendor "Linux" for product "Linux Kernel" | >= 5.19 < 6.11.6 Search vendor "Linux" for product "Linux Kernel" and version " >= 5.19 < 6.11.6" | en |
Affected
| ||||||
Linux Search vendor "Linux" | Linux Kernel Search vendor "Linux" for product "Linux Kernel" | >= 5.19 < 6.12-rc5 Search vendor "Linux" for product "Linux Kernel" and version " >= 5.19 < 6.12-rc5" | en |
Affected
| ||||||
Linux Search vendor "Linux" | Linux Kernel Search vendor "Linux" for product "Linux Kernel" | 5.15.45 Search vendor "Linux" for product "Linux Kernel" and version "5.15.45" | en |
Affected
| ||||||
Linux Search vendor "Linux" | Linux Kernel Search vendor "Linux" for product "Linux Kernel" | 5.17.13 Search vendor "Linux" for product "Linux Kernel" and version "5.17.13" | en |
Affected
| ||||||
Linux Search vendor "Linux" | Linux Kernel Search vendor "Linux" for product "Linux Kernel" | 5.18.2 Search vendor "Linux" for product "Linux Kernel" and version "5.18.2" | en |
Affected
| ||||||
Linux Search vendor "Linux" | Linux Kernel Search vendor "Linux" for product "Linux Kernel" | 5.15.45 Search vendor "Linux" for product "Linux Kernel" and version "5.15.45" | en |
Affected
| ||||||
Linux Search vendor "Linux" | Linux Kernel Search vendor "Linux" for product "Linux Kernel" | 5.17.13 Search vendor "Linux" for product "Linux Kernel" and version "5.17.13" | en |
Affected
| ||||||
Linux Search vendor "Linux" | Linux Kernel Search vendor "Linux" for product "Linux Kernel" | 5.18.2 Search vendor "Linux" for product "Linux Kernel" and version "5.18.2" | en |
Affected
|