CVE-2024-42148

In the Linux kernel, the following vulnerability has been resolved: bnx2x: Fix multiple UBSAN array-index-out-of-bounds Fix UBSAN warnings that occur when using a system with 32 physical cpu cores or more, or when the user defines a number of Ethernet queues greater than or equal to FP_SB_MAX_E1x using the num_queues module parameter. Currently there is a read/write out of bounds that occurs on the array "struct stats_query_entry query" present inside the "bnx2x_fw_stats_req" struct in "drivers/net/ethernet/broadcom/bnx2x/bnx2x.h". Looking at the definition of the "struct stats_query_entry query" array: struct stats_query_entry query[FP_SB_MAX_E1x+ BNX2X_FIRST_QUEUE_QUERY_IDX]; FP_SB_MAX_E1x is defined as the maximum number of fast path interrupts and has a value of 16, while BNX2X_FIRST_QUEUE_QUERY_IDX has a value of 3 meaning the array has a total size of 19. Since accesses to "struct stats_query_entry query" are offset-ted by BNX2X_FIRST_QUEUE_QUERY_IDX, that means that the total number of Ethernet queues should not exceed FP_SB_MAX_E1x (16). However one of these queues is reserved for FCOE and thus the number of Ethernet queues should be set to [FP_SB_MAX_E1x -1] (15) if FCOE is enabled or [FP_SB_MAX_E1x] (16) if it is not. This is also described in a comment in the source code in drivers/net/ethernet/broadcom/bnx2x/bnx2x.h just above the Macro definition of FP_SB_MAX_E1x. Below is the part of this explanation that it important for this patch /* * The total number of L2 queues, MSIX vectors and HW contexts (CIDs) is * control by the number of fast-path status blocks supported by the * device (HW/FW). Each fast-path status block (FP-SB) aka non-default * status block represents an independent interrupts context that can * serve a regular L2 networking queue. However special L2 queues such * as the FCoE queue do not require a FP-SB and other components like * the CNIC may consume FP-SB reducing the number of possible L2 queues * * If the maximum number of FP-SB available is X then: * a. If CNIC is supported it consumes 1 FP-SB thus the max number of * regular L2 queues is Y=X-1 * b. In MF mode the actual number of L2 queues is Y= (X-1/MF_factor) * c. If the FCoE L2 queue is supported the actual number of L2 queues * is Y+1 * d. The number of irqs (MSIX vectors) is either Y+1 (one extra for * slow-path interrupts) or Y+2 if CNIC is supported (one additional * FP interrupt context for the CNIC). * e. The number of HW context (CID count) is always X or X+1 if FCoE * L2 queue is supported. The cid for the FCoE L2 queue is always X. */ However this driver also supports NICs that use the E2 controller which can handle more queues due to having more FP-SB represented by FP_SB_MAX_E2. Looking at the commits when the E2 support was added, it was originally using the E1x parameters: commit f2e0899f0f27 ("bnx2x: Add 57712 support"). Back then FP_SB_MAX_E2 was set to 16 the same as E1x. However the driver was later updated to take full advantage of the E2 instead of having it be limited to the capabilities of the E1x. But as far as we can tell, the array "stats_query_entry query" was still limited to using the FP-SB available to the E1x cards as part of an oversignt when the driver was updated to take full advantage of the E2, and now with the driver being aware of the greater queue size supported by E2 NICs, it causes the UBSAN warnings seen in the stack traces below. This patch increases the size of the "stats_query_entry query" array by replacing FP_SB_MAX_E1x with FP_SB_MAX_E2 to be large enough to handle both types of NICs. Stack traces: UBSAN: array-index-out-of-bounds in drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c:1529:11 index 20 is out of range for type 'stats_query_entry [19]' CPU: 12 PID: 858 Comm: systemd-network Not tainted 6.9.0-060900rc7-generic #202405052133 Hardware name: HP ProLiant DL360 Gen9/ProLiant DL360 ---truncated---
Configurations

Configuration 1 (hide)

OR cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*

History

05 Sep 2024, 17:46

Type Values Removed Values Added
CWE CWE-129
First Time Linux
Linux linux Kernel
CPE cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
CVSS v2 : unknown
v3 : unknown
v2 : unknown
v3 : 7.8
References () https://git.kernel.org/stable/c/0edae06b4c227bcfaf3ce21208d49191e1009d3b - () https://git.kernel.org/stable/c/0edae06b4c227bcfaf3ce21208d49191e1009d3b - Patch
References () https://git.kernel.org/stable/c/134061163ee5ca4759de5c24ca3bd71608891ba7 - () https://git.kernel.org/stable/c/134061163ee5ca4759de5c24ca3bd71608891ba7 - Patch
References () https://git.kernel.org/stable/c/8b17cec33892a66bbd71f8d9a70a45e2072ae84f - () https://git.kernel.org/stable/c/8b17cec33892a66bbd71f8d9a70a45e2072ae84f - Patch
References () https://git.kernel.org/stable/c/9504a1550686f53b0bab4cab31d435383b1ee2ce - () https://git.kernel.org/stable/c/9504a1550686f53b0bab4cab31d435383b1ee2ce - Patch
References () https://git.kernel.org/stable/c/b9ea38e767459111a511ed4fb74abc37db95a59d - () https://git.kernel.org/stable/c/b9ea38e767459111a511ed4fb74abc37db95a59d - Patch
References () https://git.kernel.org/stable/c/cbe53087026ad929cd3950508397e8892a6a2a0f - () https://git.kernel.org/stable/c/cbe53087026ad929cd3950508397e8892a6a2a0f - Patch
References () https://git.kernel.org/stable/c/cfb04472ce33bee2579caf4dc9f4242522f6e26e - () https://git.kernel.org/stable/c/cfb04472ce33bee2579caf4dc9f4242522f6e26e - Patch
References () https://git.kernel.org/stable/c/f1313ea92f82451923e28ab45a4aaa0e70e80b98 - () https://git.kernel.org/stable/c/f1313ea92f82451923e28ab45a4aaa0e70e80b98 - Patch

30 Jul 2024, 13:32

Type Values Removed Values Added
Summary
  • (es) En el kernel de Linux, se resolvió la siguiente vulnerabilidad: bnx2x: corrige múltiples índices de matriz UBSAN fuera de los límites. Corrige las advertencias de UBSAN que ocurren cuando se usa un sistema con 32 núcleos de CPU físicos o más, o cuando el usuario define un número. de colas Ethernet mayores o iguales a FP_SB_MAX_E1x usando el parámetro del módulo num_queues. Actualmente hay una lectura/escritura fuera de los límites que se produce en la matriz "struct stats_query_entry query" presente dentro de la estructura "bnx2x_fw_stats_req" en "drivers/net/ethernet/broadcom/bnx2x/bnx2x.h". Mirando la definición de la matriz "struct stats_query_entry query": struct stats_query_entry query[FP_SB_MAX_E1x+ BNX2X_FIRST_QUEUE_QUERY_IDX]; FP_SB_MAX_E1x se define como el número máximo de interrupciones de ruta rápida y tiene un valor de 16, mientras que BNX2X_FIRST_QUEUE_QUERY_IDX tiene un valor de 3, lo que significa que la matriz tiene un tamaño total de 19. Dado que los accesos a "struct stats_query_entry query" están compensados por BNX2X_FIRST_QUEUE_QUERY_IDX, eso significa que el número total de colas Ethernet no debe exceder FP_SB_MAX_E1x (16). Sin embargo, una de estas colas está reservada para FCOE y, por lo tanto, el número de colas Ethernet debe establecerse en [FP_SB_MAX_E1x -1] (15) si FCOE está habilitado o [FP_SB_MAX_E1x] (16) si no lo está. Esto también se describe en un comentario en el código fuente en drivers/net/ethernet/broadcom/bnx2x/bnx2x.h justo encima de la definición de macro de FP_SB_MAX_E1x. A continuación se muestra la parte de esta explicación que es importante para este parche /* * El número total de colas L2, vectores MSIX y contextos HW (CID) está * controlado por el número de bloques de estado de ruta rápida admitidos por el * dispositivo (HW /FW). Cada bloque de estado de ruta rápida (FP-SB), también conocido como bloque de estado no predeterminado *, representa un contexto de interrupciones independiente que puede * servir a una cola de red L2 normal. Sin embargo, las colas L2 especiales, como * como la cola FCoE, no requieren un FP-SB y otros componentes como * el CNIC pueden consumir FP-SB, lo que reduce el número de colas L2 posibles * * Si el número máximo de FP-SB disponibles es X, entonces : * a. Si se admite CNIC, consume 1 FP-SB, por lo que el número máximo de * colas L2 regulares es Y=X-1 * b. En el modo MF, el número real de colas L2 es Y= (X-1/MF_factor) * c. Si se admite la cola FCoE L2, el número real de colas L2 * es Y+1 * d. El número de irqs (vectores MSIX) es Y+1 (uno adicional para * interrupciones de ruta lenta) o Y+2 si se admite CNIC (un contexto de interrupción * FP adicional para el CNIC). * e. El número de contexto de HW (recuento de CID) siempre es X o X+1 si se admite la cola FCoE * L2. El cid para la cola FCoE L2 siempre es X. */ Sin embargo, este controlador también admite NIC que usan el controlador E2, que puede manejar más colas debido a que tiene más FP-SB representado por FP_SB_MAX_E2. Al observar las confirmaciones cuando se agregó el soporte E2, originalmente se usaban los parámetros E1x: commit f2e0899f0f27 ("bnx2x: Add 57712 support"). En aquel entonces, FP_SB_MAX_E2 se configuró en 16 al igual que E1x. Sin embargo, el controlador se actualizó posteriormente para aprovechar al máximo el E2 en lugar de limitarlo a las capacidades del E1x. Pero hasta donde sabemos, la "consulta stats_query_entry" de la matriz todavía se limitaba a usar el FP-SB disponible para las tarjetas E1x como parte de una sobreseñal cuando se actualizó el controlador para aprovechar al máximo el E2, y ahora con el Al ser consciente el controlador del mayor tamaño de cola admitido por las NIC E2, se generan las advertencias de UBSAN que se ven en los seguimientos de pila a continuación. Este parche aumenta el tamaño de la matriz "stats_query_entry query" reemplazando FP_SB_MAX_E1x con FP_SB_MAX_E2 para que sea lo suficientemente grande como para manejar ambos tipos de NIC. Seguimientos de pila: UBSAN: ---truncado---

30 Jul 2024, 08:15

Type Values Removed Values Added
New CVE

Information

Published : 2024-07-30 08:15

Updated : 2024-09-05 17:46


NVD link : CVE-2024-42148

Mitre link : CVE-2024-42148

CVE.ORG link : CVE-2024-42148


JSON object : View

Products Affected

linux

  • linux_kernel
CWE
CWE-129

Improper Validation of Array Index