DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Hari Kumar Vemula <hari.kumarx.vemula@intel.com>
Cc: dev@dpdk.org, reshma.pattan@intel.com,  "Yigit,
	Ferruh" <ferruh.yigit@intel.com>,
	stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] eal: fix core number validation
Date: Wed, 2 Jan 2019 15:23:54 +0100	[thread overview]
Message-ID: <CAJFAV8wJDpjKobNTNCGrVCQj4sd-FK3=5zhbCux8jBQBbMVRcg@mail.gmail.com> (raw)
In-Reply-To: <1545300049-7463-1-git-send-email-hari.kumarx.vemula@intel.com>

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 <hari.kumarx.vemula@intel.com>
> ---
>  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

      parent reply	other threads:[~2019-01-02 14:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-20 10:00 Hari Kumar Vemula
2018-12-21  8:27 ` David Marchand
2018-12-21  9:19   ` Burakov, Anatoly
2018-12-21  9:28     ` David Marchand
2019-01-02 12:47       ` Vemula, Hari KumarX
2019-01-02 14:23 ` David Marchand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJFAV8wJDpjKobNTNCGrVCQj4sd-FK3=5zhbCux8jBQBbMVRcg@mail.gmail.com' \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=hari.kumarx.vemula@intel.com \
    --cc=reshma.pattan@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).