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 E960C43206; Thu, 26 Oct 2023 12:03:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA42A402CE; Thu, 26 Oct 2023 12:03:11 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id B7430402C5 for ; Thu, 26 Oct 2023 12:03:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698314589; x=1729850589; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fih+sKe+QZ0Z/OrmVZFfWFUTjjK59BxTp/+8DhsQefk=; b=lT3cSHrjJXQ6OMOZ0/2Og0XCC4q0X5jOsS/XhxKfJcU8wi0Qw7cpaYqm De/g042utAz3NqdH7f/yk43hXMymp42dihk6RavZ3P1MvWquDqFJmdHEC MGGtcsqMoSpJgnR4u/Lo5yzidShEZK0iz0IKTSlywdoL5b9lUSxaWEhIZ IuBWLM9/yRALfFM7ZE1Hcv0Cv0Votbg/4J0FBPCpMG2s19KBf3oNXbrIk nuyFnYRfCuPisiXfOzN5WdkKnQRSoO3netQDJzeQXWGKiowVqC9ZMUCCC dXzW3k6hVhhrYZ368onUH4A59B0QY0VZl1VFG/ykRnjpG1KUkeabrkqko w==; X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="372552634" X-IronPort-AV: E=Sophos;i="6.03,253,1694761200"; d="scan'208";a="372552634" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 03:03:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,253,1694761200"; d="scan'208";a="6876638" Received: from unknown (HELO localhost.localdomain) ([10.239.252.253]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 03:01:44 -0700 From: Mingjin Ye To: dev@dpdk.org Cc: qiming.yang@intel.com, yidingx.zhou@intel.com, Mingjin Ye , Cheng Jiang Subject: [PATCH v2] app/dma-perf: fix lcores array out of bounds access Date: Thu, 26 Oct 2023 09:53:13 +0000 Message-Id: <20231026095313.3053665-1-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230720100937.440849-1-mingjinx.ye@intel.com> References: <20230720100937.440849-1-mingjinx.ye@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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The default size of the lcores array in the lcore dma map is MAX_WORKER_NB. However, when parsing configuration parameters, MAX_LCORE_NB is used as a constraint. Since MAX_LCORE_NB is greater than MAX_WORKER_NB, this causes array access to go out of bounds when the value of the `lcore_dma/lcore` configuration item in the parameter file is greater than MAX_WORKER_NB. This patch fixes the issue by removing the MAX_LCORE_NB macro and using MAX_WORKER_NB consistently. Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test") Signed-off-by: Mingjin Ye --- v2:A better solution. --- app/test-dma-perf/main.c | 4 ++-- app/test-dma-perf/main.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c index e5bccc27da..5f8bab8f45 100644 --- a/app/test-dma-perf/main.c +++ b/app/test-dma-perf/main.c @@ -177,7 +177,7 @@ parse_lcore(struct test_configure *test_case, const char *value) char *token = strtok(input, ", "); while (token != NULL) { - if (lcore_dma_map->cnt >= MAX_LCORE_NB) { + if (lcore_dma_map->cnt >= MAX_WORKER_NB) { free(input); return -1; } @@ -248,7 +248,7 @@ parse_lcore_dma(struct test_configure *test_case, const char *value) } lcore_dma_map = &test_case->lcore_dma_map; - if (lcore_dma_map->cnt >= MAX_LCORE_NB) { + if (lcore_dma_map->cnt >= MAX_WORKER_NB) { fprintf(stderr, "lcores count error\n"); ret = -1; break; diff --git a/app/test-dma-perf/main.h b/app/test-dma-perf/main.h index f65e264378..62085e6e8f 100644 --- a/app/test-dma-perf/main.h +++ b/app/test-dma-perf/main.h @@ -14,7 +14,6 @@ #define MAX_OUTPUT_STR_LEN 512 #define MAX_DMA_NB 128 -#define MAX_LCORE_NB 256 extern char output_str[MAX_WORKER_NB + 1][MAX_OUTPUT_STR_LEN]; -- 2.25.1