From patchwork Thu Dec 20 10:00:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hari Kumar Vemula X-Patchwork-Id: 49165 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1AE4E1B9D8; Thu, 20 Dec 2018 11:01:27 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id E59351B0FF; Thu, 20 Dec 2018 11:01:25 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2018 02:01:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,376,1539673200"; d="scan'208";a="112060607" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 20 Dec 2018 02:01:23 -0800 Received: from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com [10.102.246.100]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id wBKA1MnZ006915; Thu, 20 Dec 2018 10:01:22 GMT Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id wBKA0q1b007861; Thu, 20 Dec 2018 10:00:52 GMT Received: (from hvemulax@localhost) by wgcvswdev001.ir.intel.com with ? id wBKA0qGx007857; Thu, 20 Dec 2018 10:00:52 GMT From: Hari Kumar Vemula To: dev@dpdk.org Cc: reshma.pattan@intel.com, ferruh.yigit@intel.com, Hari Kumar Vemula , stable@dpdk.org Date: Thu, 20 Dec 2018 10:00:49 +0000 Message-Id: <1545300049-7463-1-git-send-email-hari.kumarx.vemula@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] eal: fix core number validation 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" When incorrect core value or range provided, as part of -l command line option, a crash occurs. Added valid range checks to fix the crash. Fixes: d888cb8b9613 ("eal: add core list input format") Cc: stable@dpdk.org Signed-off-by: Hari Kumar Vemula --- lib/librte_eal/common/eal_common_options.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index e31eca5c0..ea6bb508b 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -602,6 +602,14 @@ eal_parse_corelist(const char *corelist) max = idx; if (min == RTE_MAX_LCORE) min = idx; + if ((unsigned int)idx >= cfg->lcore_count || + (unsigned int)min >= cfg->lcore_count) { + RTE_LOG(ERR, EAL, + "Invalid core number given core range should be(0-%u)\n", + cfg->lcore_count); + return -1; + } + for (idx = min; idx <= max; idx++) { if (cfg->lcore_role[idx] != ROLE_RTE) { cfg->lcore_role[idx] = ROLE_RTE;