From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F612A0599; Fri, 10 Apr 2020 03:03:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 04DE21D423; Fri, 10 Apr 2020 03:03:44 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id AD27C1D41D for ; Fri, 10 Apr 2020 03:03:42 +0200 (CEST) IronPort-SDR: 1NGgma3nSyHZck3HtXOs1MzWhb+BQwHVWd10cRYr4gjuQ7fmn/PQ1jRu/jyWdKRZf+ql+q13ht pGtJMfpsD5kA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2020 18:03:42 -0700 IronPort-SDR: BeQYsEDo/NpkkzJY4TwB2/T8Mju2Nzl/gjRZ9u3UcX2yrnuIBpjiZfNXEwFM/t3sUUXjJX8MMr vr+fKuSit5oA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,364,1580803200"; d="scan'208";a="259525545" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([172.16.182.123]) by orsmga008.jf.intel.com with ESMTP; 09 Apr 2020 18:03:40 -0700 From: Wei Zhao To: dev@dpdk.org Cc: qi.z.zhang@intel.com, nannan.lu@intel.com, yuan.peng@intel.com, Wei Zhao Date: Fri, 10 Apr 2020 08:41:55 +0800 Message-Id: <20200410004157.3032-2-wei.zhao1@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200410004157.3032-1-wei.zhao1@intel.com> References: <20200410004157.3032-1-wei.zhao1@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 1/3] net/ice/base: check the number of recipe when in chain X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" when we add some long switch rule, we need check the number of final recipe number, if it is large than ICE_MAX_CHAIN_RECIPE, we should refuse this rule. For example: "flow create 0 ingress pattern eth / ipv6 src is CDCD:910A:2222:5498:8475:1111:3900:1536 dst is CDCD:910A:2222:5498:8475:1111:3900:2022 tc is 3 / udp dst is 45 / end actions queue index 2 / end" This rule will consum 6 recipe, if it is not refused, it will cause the following code over write of lkup_indx and mask. LIST_FOR_EACH_ENTRY(entry, &rm->rg_list, ice_recp_grp_entry, l_entry) { last_chain_entry->fv_idx[i] = entry->chain_idx; buf[recps].content.lkup_indx[i] = entry->chain_idx; buf[recps].content.mask[i++] = CPU_TO_LE16(0xFFFF); .......... } Signed-off-by: Wei Zhao --- drivers/net/ice/base/ice_switch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index b5aa5abd9..c17219274 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -5352,6 +5352,9 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm, rm->n_grp_count++; } + if (rm->n_grp_count > ICE_MAX_CHAIN_RECIPE) + return ICE_ERR_MAX_LIMIT; + tmp = (struct ice_aqc_recipe_data_elem *)ice_calloc(hw, ICE_MAX_NUM_RECIPES, sizeof(*tmp)); -- 2.19.1