UBUNTU-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---
02 / AFFECTED SOFTWARE
Affected packages
11 explicit affected versions
35 explicit affected versions
49 explicit affected versions
50 explicit affected versions
6 explicit affected versions
12 explicit affected versions
19 explicit affected versions
6 explicit affected versions
58 explicit affected versions
57 explicit affected versions
10 explicit affected versions
44 explicit affected versions
65 explicit affected versions
54 explicit affected versions
44 explicit affected versions
10 explicit affected versions
3 explicit affected versions
9 explicit affected versions
51 explicit affected versions
191 explicit affected versions
7 explicit affected versions
50 explicit affected versions
4 explicit affected versions
92 explicit affected versions
13 explicit affected versions
85 explicit affected versions
6 explicit affected versions
35 explicit affected versions
11 explicit affected versions
16 explicit affected versions
18 explicit affected versions
12 explicit affected versions
118 explicit affected versions
37 explicit affected versions
9 explicit affected versions
94 explicit affected versions
13 explicit affected versions
4 explicit affected versions
121 explicit affected versions
23 explicit affected versions
13 explicit affected versions
1 explicit affected versions
21 explicit affected versions
16 explicit affected versions
10 explicit affected versions
49 explicit affected versions
11 explicit affected versions
7 explicit affected versions
12 explicit affected versions
111 explicit affected versions
42 explicit affected versions
12 explicit affected versions
14 explicit affected versions
7 explicit affected versions
82 explicit affected versions
12 explicit affected versions
97 explicit affected versions
105 explicit affected versions
12 explicit affected versions
4 explicit affected versions
93 explicit affected versions
120 explicit affected versions
11 explicit affected versions
5 explicit affected versions
10 explicit affected versions
37 explicit affected versions
13 explicit affected versions
2 explicit affected versions
10 explicit affected versions
31 explicit affected versions
1 explicit affected versions
34 explicit affected versions
26 explicit affected versions
13 explicit affected versions
144 explicit affected versions
6 explicit affected versions
1 explicit affected versions
29 explicit affected versions
85 explicit affected versions
13 explicit affected versions
55 explicit affected versions
3 explicit affected versions
4 explicit affected versions
1 explicit affected versions
80 explicit affected versions
53 explicit affected versions
97 explicit affected versions
15 explicit affected versions
33 explicit affected versions
23 explicit affected versions
10 explicit affected versions
1 explicit affected versions
188 explicit affected versions
11 explicit affected versions
12 explicit affected versions
7 explicit affected versions
12 explicit affected versions
95 explicit affected versions
138 explicit affected versions
2 explicit affected versions
42 explicit affected versions
36 explicit affected versions
132 explicit affected versions
52 explicit affected versions
165 explicit affected versions
154 explicit affected versions
10 explicit affected versions
26 explicit affected versions
11 explicit affected versions
31 explicit affected versions
1 explicit affected versions
3 explicit affected versions
12 explicit affected versions
13 explicit affected versions
11 explicit affected versions
139 explicit affected versions
55 explicit affected versions
16 explicit affected versions
55 explicit affected versions
12 explicit affected versions
43 explicit affected versions
116 explicit affected versions
3 explicit affected versions
93 explicit affected versions
1 explicit affected versions
2 explicit affected versions
62 explicit affected versions
51 explicit affected versions
92 explicit affected versions
9 explicit affected versions
12 explicit affected versions
41 explicit affected versions
27 explicit affected versions
27 explicit affected versions
1 explicit affected versions
1 explicit affected versions
98 explicit affected versions
5 explicit affected versions
8 explicit affected versions
16 explicit affected versions
5 explicit affected versions
8 explicit affected versions
1 explicit affected versions
10 explicit affected versions
8 explicit affected versions
13 explicit affected versions
84 explicit affected versions
13 explicit affected versions
49 explicit affected versions
7 explicit affected versions
140 explicit affected versions
94 explicit affected versions
46 explicit affected versions
10 explicit affected versions
13 explicit affected versions
12 explicit affected versions
84 explicit affected versions
44 explicit affected versions
16 explicit affected versions
3 explicit affected versions
13 explicit affected versions
26 explicit affected versions
41 explicit affected versions
37 explicit affected versions
12 explicit affected versions
14 explicit affected versions
38 explicit affected versions
167 explicit affected versions
44 explicit affected versions
9 explicit affected versions
44 explicit affected versions
11 explicit affected versions
4 explicit affected versions
52 explicit affected versions
7 explicit affected versions
25 explicit affected versions
97 explicit affected versions
56 explicit affected versions
121 explicit affected versions
4 explicit affected versions
1 explicit affected versions
1 explicit affected versions
50 explicit affected versions
13 explicit affected versions
43 explicit affected versions
50 explicit affected versions
10 explicit affected versions
8 explicit affected versions
7 explicit affected versions
14 explicit affected versions
85 explicit affected versions
4 explicit affected versions
74 explicit affected versions
11 explicit affected versions
1 explicit affected versions
69 explicit affected versions
5 explicit affected versions
03 / CONNECTIONS
Connected vulnerabilities
04 / EVIDENCE
Source records
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---
05 / REFERENCES
Further evidence
- https://git.kernel.org/linus/134061163ee5ca4759de5c24ca3bd71608891ba7
- https://git.kernel.org/stable/c/0edae06b4c227bcfaf3ce21208d49191e1009d3b
- https://git.kernel.org/stable/c/134061163ee5ca4759de5c24ca3bd71608891ba7
- https://git.kernel.org/stable/c/8b17cec33892a66bbd71f8d9a70a45e2072ae84f
- https://git.kernel.org/stable/c/9504a1550686f53b0bab4cab31d435383b1ee2ce
- https://git.kernel.org/stable/c/b9ea38e767459111a511ed4fb74abc37db95a59d
- https://git.kernel.org/stable/c/cbe53087026ad929cd3950508397e8892a6a2a0f
- https://git.kernel.org/stable/c/cfb04472ce33bee2579caf4dc9f4242522f6e26e
- https://git.kernel.org/stable/c/f1313ea92f82451923e28ab45a4aaa0e70e80b98
- https://ubuntu.com/security/CVE-2024-42148
- https://ubuntu.com/security/notices/USN-6999-1
- https://ubuntu.com/security/notices/USN-6999-2
- https://ubuntu.com/security/notices/USN-7003-1
- https://ubuntu.com/security/notices/USN-7003-2
- https://ubuntu.com/security/notices/USN-7003-3
- https://ubuntu.com/security/notices/USN-7003-4
- https://ubuntu.com/security/notices/USN-7003-5
- https://ubuntu.com/security/notices/USN-7004-1
- https://ubuntu.com/security/notices/USN-7005-1
- https://ubuntu.com/security/notices/USN-7005-2
- https://ubuntu.com/security/notices/USN-7006-1
- https://ubuntu.com/security/notices/USN-7007-1
- https://ubuntu.com/security/notices/USN-7007-2
- https://ubuntu.com/security/notices/USN-7007-3
- https://ubuntu.com/security/notices/USN-7008-1
- https://ubuntu.com/security/notices/USN-7009-1
- https://ubuntu.com/security/notices/USN-7009-2
- https://ubuntu.com/security/notices/USN-7019-1
- https://ubuntu.com/security/notices/USN-7029-1
- https://www.cve.org/CVERecord?id=CVE-2024-42148