DPDK patches and discussions
 help / color / mirror / Atom feed
From: Mingjin Ye <mingjinx.ye@intel.com>
To: dev@dpdk.org
Cc: qiming.yang@intel.com, yidingx.zhou@intel.com,
	Mingjin Ye <mingjinx.ye@intel.com>,
	Cheng Jiang <honest.jiang@foxmail.com>
Subject: [PATCH v2] app/dma-perf: fix lcores array out of bounds access
Date: Thu, 26 Oct 2023 09:53:13 +0000	[thread overview]
Message-ID: <20231026095313.3053665-1-mingjinx.ye@intel.com> (raw)
In-Reply-To: <20230720100937.440849-1-mingjinx.ye@intel.com>

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 <mingjinx.ye@intel.com>
---
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


  reply	other threads:[~2023-10-26 10:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 10:09 [PATCH] app/dma-perf: fix dma mapping access overruns Mingjin Ye
2023-10-26  9:53 ` Mingjin Ye [this message]
2023-10-27 14:27   ` [EXT] [PATCH v2] app/dma-perf: fix lcores array out of bounds access Gowrishankar Muthukrishnan
2023-11-14 14:37   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231026095313.3053665-1-mingjinx.ye@intel.com \
    --to=mingjinx.ye@intel.com \
    --cc=dev@dpdk.org \
    --cc=honest.jiang@foxmail.com \
    --cc=qiming.yang@intel.com \
    --cc=yidingx.zhou@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).