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 B0B53A0A0E; Thu, 29 Apr 2021 04:34:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85EBA412D4; Thu, 29 Apr 2021 04:34:20 +0200 (CEST) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id 3956440697 for ; Thu, 29 Apr 2021 04:34:15 +0200 (CEST) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FVzz42pcszvTSb; Thu, 29 Apr 2021 10:31:44 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Thu, 29 Apr 2021 10:34:09 +0800 From: "Min Hu (Connor)" To: CC: , , , Date: Thu, 29 Apr 2021 10:34:13 +0800 Message-ID: <1619663653-22771-3-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1619663653-22771-1-git-send-email-humin29@huawei.com> References: <1618967837-2341-1-git-send-email-humin29@huawei.com> <1619663653-22771-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v2 2/2] eal: fix service core index validity 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" This patch adds checking for service core index validity when parsing service corelist. Fixes: 7dbd7a6413ef ("service: add -S corelist option") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) --- lib/eal/common/eal_common_options.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 66f9114..97ab6e0 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -758,10 +758,10 @@ static int eal_parse_service_corelist(const char *corelist) { struct rte_config *cfg = rte_eal_get_configuration(); - int i, idx = 0; + int i; unsigned count = 0; char *end = NULL; - int min, max; + uint32_t min, max, idx; uint32_t taken_lcore_count = 0; if (corelist == NULL) @@ -785,6 +785,8 @@ eal_parse_service_corelist(const char *corelist) idx = strtoul(corelist, &end, 10); if (errno || end == NULL) return -1; + if (idx >= RTE_MAX_LCORE) + return -1; while (isblank(*end)) end++; if (*end == '-') { -- 2.7.4