net/i40e: fix 32-bit build

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.

Fixes: 6ced3dd72f ("net/i40e: support flexible payload parsing for FDIR")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
This commit is contained in:
Ferruh Yigit 2021-10-29 11:37:01 +01:00 committed by Qi Zhang
parent 7f49dafe05
commit d01201829b

View File

@ -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] =