From patchwork Mon Sep 4 13:37:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 28327 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 98B557CBE; Mon, 4 Sep 2017 15:37:24 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 65E527CBD for ; Mon, 4 Sep 2017 15:37:22 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2017 06:37:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,474,1498546800"; d="scan'208";a="145297825" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga005.jf.intel.com with ESMTP; 04 Sep 2017 06:37:20 -0700 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.49]) by IRSMSX102.ger.corp.intel.com ([169.254.2.59]) with mapi id 14.03.0319.002; Mon, 4 Sep 2017 14:37:19 +0100 From: "Singh, Jasvinder" To: Rongqiang XIE , "Dumitrescu, Cristian" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound Thread-Index: AQHTG956AiheTBzCgUaVYrLatN3JfKKkymGA Date: Mon, 4 Sep 2017 13:37:19 +0000 Message-ID: <54CBAA185211B4429112C315DA58FF6D33247563@IRSMSX103.ger.corp.intel.com> References: <1503471932-22577-1-git-send-email-xie.rongqiang@zte.com.cn> In-Reply-To: <1503471932-22577-1-git-send-email-xie.rongqiang@zte.com.cn> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.182] MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound 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" Hi Xie, -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Rongqiang XIE Sent: Wednesday, August 23, 2017 8:06 AM To: Dumitrescu, Cristian Cc: dev@dpdk.org; Rongqiang XIE Subject: [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound In function rte_pipeline_compute_masks(), the value pos equal p->entries[i]->action,type constraint p->entries[i]->action is [0,4],but array action_mask1 size is 4,it possible attempt to access element 4 of array action_mask1.And also in function rte_pipeline_run(),it possible attempt to access element 4 of array action_mask0. Signed-off-by: Rongqiang XIE --- lib/librte_pipeline/rte_pipeline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) How about making library more robust by introducing some checks to make sure that action field value doesn't overshoot? The action field value can be checked in the following functions meant for adding table entries. rte_pipeline_table_default_entry_add(), rte_pipeline_table_entry_add(), rte_pipeline_table_entry_add_bulk() diff --git a/lib/librte_pipeline/rte_pipeline.c b/lib/librte_pipeline/rte_pipeline.c index 7f8fbac..2914445 100644 --- a/lib/librte_pipeline/rte_pipeline.c +++ b/lib/librte_pipeline/rte_pipeline.c @@ -155,8 +155,8 @@ struct rte_pipeline { /* Pipeline run structures */ struct rte_mbuf *pkts[RTE_PORT_IN_BURST_SIZE_MAX]; struct rte_pipeline_table_entry *entries[RTE_PORT_IN_BURST_SIZE_MAX]; - uint64_t action_mask0[RTE_PIPELINE_ACTIONS]; - uint64_t action_mask1[RTE_PIPELINE_ACTIONS]; + uint64_t action_mask0[RTE_PIPELINE_ACTIONS + 1]; + uint64_t action_mask1[RTE_PIPELINE_ACTIONS + 1]; uint64_t pkts_mask; uint64_t n_pkts_ah_drop; uint64_t pkts_drop_mask;