Skip to contentSkip to conversation

net/i40e: fix build for 32-bit

PATCH Applied Ferruh Yigit 2 participants 2 messages Oct 29, 2021 – Nov 1, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/i40e: fix build for 32-bit

Got error with: gcc 11.2.1 "cc (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1)"

Build error:
In function ‘i40e_flow_parse_fdir_pattern’,
inlined from ‘i40e_flow_parse_fdir_filter’
at ../drivers/net/i40e/i40e_flow.c:3274:8:
../drivers/net/i40e/i40e_flow.c:3052:69:
error: writing 1 byte into a region of size 0
[-Werror=stringop-overflow=]

 3052 |                         filter->input.flow_ext.flexbytes[j] =
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 3053 |                                 raw_spec->pattern[i];
      |                                 ~~~~~~~~~~~~~~~~~~~~

In file included from ../drivers/net/i40e/i40e_flow.c:25:
../drivers/net/i40e/i40e_flow.c:
In function ‘i40e_flow_parse_fdir_filter’:
../drivers/net/i40e/i40e_ethdev.h:638:17:
note: at offset 16 into destination object ‘flexbytes’ of size 16

  638 |         uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
      |                 ^~~~~~~~~

Fixing by adding range checks.

---
Cc: Qi Z Zhang <[email protected]>

Not sure why only 32-bit is causing this error, or if the overflow practically can occurs.

./devtools/test-meson-builds.sh is not catching the warning because of '--buildtype=debugoptimized'.

I can reproduce in my environment as following:
PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig meson --werror -Dc_args=-m32 -Dc_link_args=-m32 build && ninja -C build

---
 drivers/net/i40e/i40e_flow.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/i40e/i40e_flow.c +3 -0
index 9acaa1875105..c9676caab5dd 100644
@@ -3049,6 +3049,9 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 
 			for (i = 0; i < raw_spec->length; i++) {
 				j = i + next_dst_off;
+				if (j >= RTE_ETH_FDIR_MAX_FLEXLEN ||
+						j >= I40E_FDIR_MAX_FLEX_LEN)
+					break;
 				filter->input.flow_ext.flexbytes[j] =
 					raw_spec->pattern[i];
 				filter->input.flow_ext.flex_mask[j] =
Signature · 1 line
2.31.1
Acked-by on v1 1/1 Applied
#1 lore raw
Quoted 29 lines

-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 29, 2021 6:37 PM
To: Xing, Beilei <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; [email protected]; Zhang, Qi Z <[email protected]>
Subject: [PATCH] net/i40e: fix build for 32-bit

Got error with: gcc 11.2.1 "cc (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1)"

Build error:
In function ‘i40e_flow_parse_fdir_pattern’,
inlined from ‘i40e_flow_parse_fdir_filter’ at ../drivers/net/i40e/i40e_flow.c:3274:8:
../drivers/net/i40e/i40e_flow.c:3052:69:
error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
3052 | filter->input.flow_ext.flexbytes[j] =

      |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 3053 |                                 raw_spec->pattern[i];
      |                                 ~~~~~~~~~~~~~~~~~~~~

In file included from ../drivers/net/i40e/i40e_flow.c:25:
../drivers/net/i40e/i40e_flow.c:
In function ‘i40e_flow_parse_fdir_filter’:
../drivers/net/i40e/i40e_ethdev.h:638:17:
note: at offset 16 into destination object ‘flexbytes’ of size 16

Quoted 6 lines
  638 |         uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
      |                 ^~~~~~~~~

Fixing by adding range checks.

Applied to dpdk-next-net-intel after added below fixline and Cc stable.

Fixes 6ced3dd72f5f ("net/i40e: support flexible payload parsing for FDIR")

Thanks
Qi