From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-f66.google.com (mail-vs1-f66.google.com [209.85.217.66]) by dpdk.org (Postfix) with ESMTP id 3D4A91B216 for ; Wed, 2 Jan 2019 15:24:07 +0100 (CET) Received: by mail-vs1-f66.google.com with SMTP id n13so18959524vsk.4 for ; Wed, 02 Jan 2019 06:24:07 -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=BPjHuZ1NNpgTv+36OivHdFprb+clIn1BlOZnWuXmCXwHW08CyH/MM5NoSrpoXTOiJ7 0BWfOxZDQJ4hxZY1mfDWxpbcfMjhOJVTAzF+aapQWZpnjnXpWhdscfEfbuWVwn9uFfdt O8QmIXIroubIGknnVYoNYOs7WLti83P2EwgsAzCbc6Bp7imnG8E1Y3/cBwZDmGtk5x/E KgyhOcxR9KwpoFlMtMlQPctgt5IYOZmjO7Qfa0txSTcNoIIdPSw6r8lQuwh+/MUFZiK5 un3h0BZEhw7/nv3B2n1OTq+ITUohaZhahTOXjGIMxZTWbyeydmBCXfozxvOq9jclcEdD F0cA== X-Gm-Message-State: AA+aEWb8pL+8yCe+/T3+FKQC+/2h6uwlYEU+PTcNH5zBytjYD82865Gr y4SB17Yhx+U+ACfGnD75eQ8Pns10xHwWmVKGyVZ6Pg== 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-stable] [dpdk-dev] [PATCH] eal: fix core number validation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jan 2019 14:24:07 -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