From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-f68.google.com (mail-vs1-f68.google.com [209.85.217.68]) by dpdk.org (Postfix) with ESMTP id 1502E1B216 for ; Wed, 2 Jan 2019 15:24:08 +0100 (CET) Received: by mail-vs1-f68.google.com with SMTP id v205so18948797vsc.3 for ; Wed, 02 Jan 2019 06:24:08 -0800 (PST) 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=CMCCbPU+EpS1YBodC3hDC8HCmEhFqCiGr+tvg3CiFLI=; b=Jl4/P6RLoCiQ+G8xu3y5rrGZEXaqf4KhjZdUIXAajxra8gUeOxDmv3t65f+7j8t8MD HjVb3WkiJZkHcBZ2iGS5H6A6e8uco7B6VvbqqEQ2bdxyothOgHJadHD54GHeB9ZTbYI2 /+GMTWNIezfDT9IS3njt46AbBkurXq5HdX4iw9UeOB/Wohl9ciikw8sHuYDN4j03qzs2 ndrv79o9c1lunh2tpoupVzFHyHS3iMp5VQxZMLcm/lXtk3phwg3itIKdY7AnDj/uyi4I C1bCNHw04IHw19GxcKhl1V0bEYZo4pa8Ss0WrvgwtDtdxrqlW/xehh2dkb+fJ7YwOH62 UCBQ== X-Gm-Message-State: AA+aEWa2dGDwnPsz6xtbx9Cm8YCG1e1gz45k18kt9c3NoV+grcr54nhY Ue1euIZZkvOkr6KD3H53Zoo/9N38U2VLpbO6HNbK8A== X-Google-Smtp-Source: ALg8bN5KVnlsfzfx23GaNboluHiHdSMdFDne1+RzI79X1+jAW0y+O7fD8xose6VOap0u8drDqLPg9gdZrf+reArBcVk= X-Received: by 2002:a67:1b04:: with SMTP id b4mr17573876vsb.141.1546439046622; Wed, 02 Jan 2019 06:24:06 -0800 (PST) MIME-Version: 1.0 References: <1545300049-7463-1-git-send-email-hari.kumarx.vemula@intel.com> In-Reply-To: <1545300049-7463-1-git-send-email-hari.kumarx.vemula@intel.com> From: David Marchand Date: Wed, 2 Jan 2019 15:23:54 +0100 Message-ID: To: Hari Kumar Vemula Cc: dev@dpdk.org, reshma.pattan@intel.com, "Yigit, Ferruh" , stable@dpdk.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [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: , X-List-Received-Date: Wed, 02 Jan 2019 14:24:08 -0000 On Thu, Dec 20, 2018 at 11:01 AM Hari Kumar Vemula < hari.kumarx.vemula@intel.com> wrote: > 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) { > Rather than check those conditions here, check directly after parsing the input string. Those casts will have side effects with negative values and the use of current strtoul is suspicious to me. You should switch to strtol, check for negative values and for the max value according to cfg->lcore_count. > + RTE_LOG(ERR, EAL, > + "Invalid core number given core > range should be(0-%u)\n", > + cfg->lcore_count); > This log message will be a duplicate with the message in eal_parse_common_option() so please drop this. We could add the range in the current log message in eal_parse_common_option(), but please, the range is [0, cfg->lcore_count - 1]. + return -1; > + } > + > for (idx = min; idx <= max; idx++) { > if (cfg->lcore_role[idx] != ROLE_RTE) { > cfg->lcore_role[idx] = ROLE_RTE; > -- David Marchand