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 E4B05A0547; Thu, 29 Apr 2021 10:11:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D046B41125; Thu, 29 Apr 2021 10:11:32 +0200 (CEST) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mails.dpdk.org (Postfix) with ESMTP id 2668D4067E for ; Thu, 29 Apr 2021 10:11:31 +0200 (CEST) Received: by mail-pf1-f179.google.com with SMTP id c19so916728pfv.2 for ; Thu, 29 Apr 2021 01:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d2/Mo2emJA4VQlEIQ9fI9uHiUIpaZmsaum+pa/ZdayQ=; b=HOCvMed7HLQFtDWGqduA1THqYLbUl82e0Xf49FNXdMnnSWRlXnNgkdmJhwsJu8rNwC 5AuIOE5GnnJHMb6iEAgi5j0/eA/BPz90UvS4JLxbrh1OHZeOqoPdhoPLXZmR1kRGM87A qdEknLUQU9v4D7aNJh2SZhCI6CvHZn9XMySEJeCVjvz7psmvEyaOHRcLykrRLsvbOtjS N1xdamDqmVdmhavAUHWCfuVGl4mIdEELKHTH3Y1uUHTLWA4QgdoUt0p8J3aQ8XXO9dp2 klPNSPeXFX7Xz7jns/oJoLKrGnWtsgEqrQBOY950Crux1D0RVe5aShuk4FvP49zOYQTf zg8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d2/Mo2emJA4VQlEIQ9fI9uHiUIpaZmsaum+pa/ZdayQ=; b=tdVh+NE+5snevCYp5wqKPBA4E8XKcsOK4BVtIfTsB/MUnrREWSTHb6CVQncG+vjFuF QR5HjwinOCpXEwW45ad5MXB+n+G2fcWQzzVRdO44GTzWyTio6Vtob4sazhm8Qd1VtiNu UVojPpM/eYejyvZIWYaLWfgs0G34ibZf32t/j4i6xS+Kn8HzPRMFw5Au9f0iX74qz5yi I9vV2V1pvIr4dYQiUmsNtMXDiIKSq1yW+ZiJwG6iCc2iJXW6S5EHBLbb0isdmp1QM9g5 vrzGx34P1uYff9qXema75ae/sw1DEcvvGGKCdyZbFEph1DD+1wG1S0uN9q7W1Jf3EyaF Kpsw== X-Gm-Message-State: AOAM533Oc3x4/FrEXWoQR0AeiTF2yt9lvr58gRJdwAYOS1azOs8R59uc txnj8QIBLPUpdAnfLDjIFMzYGv67UbDjZ9WPgNQ= X-Google-Smtp-Source: ABdhPJzwEdBkBm43ZcR53l2+YCDtWAy3IWVV9YisPjOZ2qj5QLgAjzLvkymWw51FrLnYWeoNEsPob5rP3IyInkYMRN4= X-Received: by 2002:a63:ea53:: with SMTP id l19mr30061174pgk.176.1619683890319; Thu, 29 Apr 2021 01:11:30 -0700 (PDT) MIME-Version: 1.0 References: <1619163488-63913-1-git-send-email-humin29@huawei.com> In-Reply-To: From: Jerin Jacob Date: Thu, 29 Apr 2021 13:41:14 +0530 Message-ID: To: Pavan Nikhilesh Bhagavatula Cc: "Min Hu (Connor)" , "dev@dpdk.org" , "ferruh.yigit@intel.com" , Jerin Jacob Kollanukkaran , "thomas@monjalon.net" Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [EXT] [PATCH] app/testeventdev: fix buffer overflow 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 Sender: "dev" On Fri, Apr 23, 2021 at 2:38 PM Pavan Nikhilesh Bhagavatula wrote: > > >Tainted and unvalidated integer 'idx' used as an index, which may > >lead to buffer overflow. > > > >This patch fixed it. > > > >Fixes: 89e5eb118017 ("app/testeventdev: add string parsing helpers") > >Cc: stable@dpdk.org > > > >Signed-off-by: Min Hu (Connor) > > Acked-by: Pavan Nikhilesh Applied to dpdk-next-net-eventdev/for-main. Thanks > > >--- > > app/test-eventdev/evt_options.c | 4 ++-- > > app/test-eventdev/parser.c | 6 ++++-- > > app/test-eventdev/parser.h | 2 +- > > 3 files changed, 7 insertions(+), 5 deletions(-) > > > >diff --git a/app/test-eventdev/evt_options.c b/app/test- > >eventdev/evt_options.c > >index 0d55405..061b63e 100644 > >--- a/app/test-eventdev/evt_options.c > >+++ b/app/test-eventdev/evt_options.c > >@@ -221,7 +221,7 @@ evt_parse_plcores(struct evt_options *opt, > >const char *corelist) > > { > > int ret; > > > >- ret = parse_lcores_list(opt->plcores, corelist); > >+ ret = parse_lcores_list(opt->plcores, RTE_MAX_LCORE, > >corelist); > > if (ret == -E2BIG) > > evt_err("duplicate lcores in plcores"); > > > >@@ -233,7 +233,7 @@ evt_parse_work_lcores(struct evt_options > >*opt, const char *corelist) > > { > > int ret; > > > >- ret = parse_lcores_list(opt->wlcores, corelist); > >+ ret = parse_lcores_list(opt->wlcores, RTE_MAX_LCORE, > >corelist); > > if (ret == -E2BIG) > > evt_err("duplicate lcores in wlcores"); > > > >diff --git a/app/test-eventdev/parser.c b/app/test-eventdev/parser.c > >index 24f1855..7a973cb 100644 > >--- a/app/test-eventdev/parser.c > >+++ b/app/test-eventdev/parser.c > >@@ -310,7 +310,7 @@ parse_hex_string(char *src, uint8_t *dst, > >uint32_t *size) > > } > > > > int > >-parse_lcores_list(bool lcores[], const char *corelist) > >+parse_lcores_list(bool lcores[], int lcores_num, const char *corelist) > > { > > int i, idx = 0; > > int min, max; > >@@ -332,6 +332,8 @@ parse_lcores_list(bool lcores[], const char > >*corelist) > > if (*corelist == '\0') > > return -1; > > idx = strtoul(corelist, &end, 10); > >+ if (idx < 0 || idx > lcores_num) > >+ return -1; > > > > if (end == NULL) > > return -1; > >@@ -343,7 +345,7 @@ parse_lcores_list(bool lcores[], const char > >*corelist) > > max = idx; > > if (min == RTE_MAX_LCORE) > > min = idx; > >- for (idx = min; idx <= max; idx++) { > >+ for (idx = min; idx < max; idx++) { > > if (lcores[idx] == 1) > > return -E2BIG; > > lcores[idx] = 1; > >diff --git a/app/test-eventdev/parser.h b/app/test-eventdev/parser.h > >index 673ff22..696b40a 100644 > >--- a/app/test-eventdev/parser.h > >+++ b/app/test-eventdev/parser.h > >@@ -46,5 +46,5 @@ int parse_hex_string(char *src, uint8_t *dst, > >uint32_t *size); > > > > int parse_tokenize_string(char *string, char *tokens[], uint32_t > >*n_tokens); > > > >-int parse_lcores_list(bool lcores[], const char *corelist); > >+int parse_lcores_list(bool lcores[], int lcores_num, const char > >*corelist); > > #endif > >-- > >2.7.4 >