From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AD57DA0032; Fri, 29 Oct 2021 12:37:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6EFBD41174; Fri, 29 Oct 2021 12:37:06 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id F219141169 for ; Fri, 29 Oct 2021 12:37:04 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10151"; a="210690669" X-IronPort-AV: E=Sophos;i="5.87,192,1631602800"; d="scan'208";a="210690669" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2021 03:37:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,192,1631602800"; d="scan'208";a="466479710" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.27]) by orsmga002.jf.intel.com with ESMTP; 29 Oct 2021 03:37:02 -0700 From: Ferruh Yigit To: Beilei Xing Cc: Ferruh Yigit , dev@dpdk.org, Qi Z Zhang Date: Fri, 29 Oct 2021 11:37:01 +0100 Message-Id: <20211029103701.4094508-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/i40e: fix build for 32-bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. Signed-off-by: Ferruh Yigit --- Cc: Qi Z Zhang 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(+) diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 9acaa1875105..c9676caab5dd 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -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] = -- 2.31.1