5.5medium
bpftool: Fix undefined behavior in qsort(NULL, 0, ...)
- Severity
- 5.5medium CVSS:3.1 by NVD
- Exploit likelihood
- 0.30% (higher than 15% of CVEs)
- Published
- Last changed
- Assigned by
- Linux
Description
In the Linux kernel, the following vulnerability has been resolved: bpftool: Fix undefined behavior in qsort(NULL, 0, ...) When netfilter has no entry to display, qsort is called with qsort(NULL, 0, ...). This results in undefined behavior, as UBSan reports: net.c:827:2: runtime error: null pointer passed as argument 1, which is declared to never be null Although the C standard does not explicitly state whether calling qsort with a NULL pointer when the size is 0 constitutes undefined behavior, Section 7.1.4 of the C standard (Use of library functions) mentions: "Each of the following statements applies unless explicitly stated otherwise in the detailed descriptions that follow: If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the behavior is undefined." To avoid this, add an early return when nf_link_info is NULL to prevent calling qsort with a NULL pointer.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Linux Linux | from d0fe92fb5e3df6991c640fb9205d880b68603259 before c2d9f9a7837ab29ccae0c42252f17d436bf0a501, from d0fe92fb5e3df6991c640fb9205d880b68603259 before 2e0f6f33f2aa87493b365a38a8fd87b8854b7734, from d0fe92fb5e3df6991c640fb9205d880b68603259 before c208b02827eb642758cef65641995fd3f38c89af, from d0fe92fb5e3df6991c640fb9205d880b68603259 before f04e2ad394e2755d0bb2d858ecb5598718bf00d5, 6.4 Not affected: before 6.4, from 6.6.55 up to 6.6.*, from 6.10.14 up to 6.10.*, from 6.11.3 up to 6.11.*, from 6.12 up to * | CVE List |
| linux linux_kernel | before 6.6.55, from 6.7 before 6.10.14, from 6.11 before 6.11.3 | NVD |
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: bpftool: Fix undefined behavior in qsort(NULL, 0, ...) When netfilter has no entry to display, qsort is called with qsort(NULL, 0, ...). This results in undefined behavior, as UBSan reports: net.c:827:2: runtime error: null pointer passed as argument 1, which is declared to never be null Although the C standard does not explicitly state whether calling qsort with a NULL pointer when the size is 0 constitutes undefined behavior, Section 7.1.4 of the C standard (Use of library functions) mentions: "Each of the following statements applies unless explicitly stated otherwise in the detailed descriptions that follow: If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the behavior is undefined." To avoid this, add an early return when nf_link_info is NULL to prevent calling qsort with a NULL pointer.
NVD (es)
En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: bpftool: corrige comportamiento indefinido en qsort(NULL, 0, ...) Cuando netfilter no tiene ninguna entrada para mostrar, se llama a qsort con qsort(NULL, 0, ...). Esto da como resultado un comportamiento indefinido, como informa UBSan: net.c:827:2: error en tiempo de ejecución: puntero nulo pasado como argumento 1, que se declara que nunca será nulo Aunque el estándar C no indica explícitamente si llamar a qsort con un puntero NULL cuando el tamaño es 0 constituye un comportamiento indefinido, la Sección 7.1.4 del estándar C (Uso de funciones de librería) menciona: "Cada una de las siguientes afirmaciones se aplica a menos que se indique explícitamente lo contrario en las descripciones detalladas que siguen: si un argumento de una función tiene un valor no válido (como un valor fuera del dominio de la función, o un puntero fuera del espacio de direcciones del programa, o un puntero nulo, o un puntero a almacenamiento no modificable cuando el parámetro correspondiente no está calificado como constante) o un tipo (después de la promoción) no esperado por una función con un número variable de argumentos, el comportamiento es indefinido". Para evitar esto, agregue un retorno temprano cuando nf_link_info sea NULL para evitar llamar a qsort con un puntero NULL.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-49987 changed 2026-05-11 | CVE Terms of Use |
| NVD | CVE-2024-49987 changed 2026-06-17 | Public domain |