DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hari Kumar Vemula <hari.kumarx.vemula@intel.com>
To: dev@dpdk.org
Cc: reshma.pattan@intel.com, ferruh.yigit@intel.com,
	Hari Kumar Vemula <hari.kumarx.vemula@intel.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH] eal: fix core number validation
Date: Thu, 20 Dec 2018 10:00:49 +0000	[thread overview]
Message-ID: <1545300049-7463-1-git-send-email-hari.kumarx.vemula@intel.com> (raw)

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) {
+				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;
-- 
2.17.2

             reply	other threads:[~2018-12-20 10:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-20 10:00 Hari Kumar Vemula [this message]
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

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=1545300049-7463-1-git-send-email-hari.kumarx.vemula@intel.com \
    --to=hari.kumarx.vemula@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@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).