From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 5E3DE45500;
	Wed, 26 Jun 2024 13:59:39 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id ADFBF433C4;
	Wed, 26 Jun 2024 13:55:49 +0200 (CEST)
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9])
 by mails.dpdk.org (Postfix) with ESMTP id 43B1E42E95
 for <dev@dpdk.org>; Wed, 26 Jun 2024 13:44:11 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1719402251; x=1750938251;
 h=from:to:cc:subject:date:message-id:in-reply-to:
 references:mime-version:content-transfer-encoding;
 bh=fPQ6aumLMq8BX/xOiJDIMCU2WViFhDOMB9FGdFL0fSE=;
 b=XVNQaDvpdNl9vavbN3JoMwuKmXgwNOoqpCcUPx0E4wIa8SCeFi2CWJGG
 Kbm7cvKph5KEZsB+zCmceThtY+jVP52C+Qxrk0CSwizDordclIkYiE5N1
 1ensvauZZVrfyecICWspGXNy4VmXtbHlSpxSY66UesslRB+ZVwvtmidDa
 Bqaz7tXWh0O/Q6n7wh9qglPINdTYtN1hiENXEH3/RlFJV87o+WRI1pgUF
 ychlh8GxqUn74uEZNq/nXwZILZZ0RTkTzHgSPkMwXDRVdAHN6dj8oeNCg
 S10ThPm1GKlHiWwxpwYvaF69YLGX3QAjH7EpgyrqLdxSB0NnejSBgmHWG A==;
X-CSE-ConnectionGUID: R6MLsHPwTKeYReyR9sYiNQ==
X-CSE-MsgGUID: N5L0l+GXReWr+Fy/LiZxMQ==
X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="38979408"
X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="38979408"
Received: from orviesa010.jf.intel.com ([10.64.159.150])
 by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 26 Jun 2024 04:44:10 -0700
X-CSE-ConnectionGUID: XhZ/VqpKRsClJ0SzOYZLjg==
X-CSE-MsgGUID: 2XjOz03yT8ezcguYmf9gOA==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="43873893"
Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167])
 by orviesa010.jf.intel.com with ESMTP; 26 Jun 2024 04:44:10 -0700
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: Waldemar Dworakowski <waldemar.dworakowski@intel.com>,
 ian.stokes@intel.com, bruce.richardson@intel.com
Subject: [PATCH v4 042/103] net/ice/base: check array bounds
Date: Wed, 26 Jun 2024 12:41:30 +0100
Message-ID: <9459092c48d050df0c1c1fadeca03fb680e1c5f7.1719401848.git.anatoly.burakov@intel.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <cover.1719401847.git.anatoly.burakov@intel.com>
References: <cover.1719313663.git.anatoly.burakov@intel.com>
 <cover.1719401847.git.anatoly.burakov@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

From: Waldemar Dworakowski <waldemar.dworakowski@intel.com>

Some compilation targets were generating errors due to unchecked array bounds
when accessing recipe groups. Add a check to avoid that.

Signed-off-by: Waldemar Dworakowski <waldemar.dworakowski@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
---
 drivers/net/ice/base/ice_switch.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c
index ac73630976..153425bf42 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -7336,12 +7336,14 @@ ice_create_first_fit_recp_def(struct ice_hw *hw,
 				(*recp_cnt)++;
 			}
 
-			grp->pairs[grp->n_val_pairs].prot_id =
-				lkup_exts->fv_words[j].prot_id;
-			grp->pairs[grp->n_val_pairs].off =
-				lkup_exts->fv_words[j].off;
-			grp->mask[grp->n_val_pairs] = lkup_exts->field_mask[j];
-			grp->n_val_pairs++;
+			if (grp->n_val_pairs < ICE_NUM_WORDS_RECIPE) {
+				grp->pairs[grp->n_val_pairs].prot_id =
+					lkup_exts->fv_words[j].prot_id;
+				grp->pairs[grp->n_val_pairs].off =
+					lkup_exts->fv_words[j].off;
+				grp->mask[grp->n_val_pairs] = lkup_exts->field_mask[j];
+				grp->n_val_pairs++;
+			}
 		}
 
 	return 0;
-- 
2.43.0