From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id C4F802082 for ; Thu, 17 Jan 2019 14:13:03 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20E0CC059B7A; Thu, 17 Jan 2019 13:13:03 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-117-32.ams2.redhat.com [10.36.117.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id C60E817DE4; Thu, 17 Jan 2019 13:13:01 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: bruce.richardson@intel.com, solal.pirelli@gmail.com Date: Thu, 17 Jan 2019 14:12:57 +0100 Message-Id: <1547730777-20405-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 17 Jan 2019 13:13:03 +0000 (UTC) Subject: [dpdk-dev] [PATCH] eal: fix out of bound access when no cpu is available 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: Thu, 17 Jan 2019 13:13:04 -0000 In the unlikely case when the dpdk application is started with no cpu available in the [0, RTE_MAX_LCORE - 1] range, the master_lcore is automatically chosen as RTE_MAX_LCORE which triggers an out of bound access. Either you have a crash then, or the initialisation fails later when trying to pin the master thread on it. In my test, with RTE_MAX_LCORE == 2: $ taskset -c 2 ./master/app/testpmd --no-huge -m 512 --log-level *:debug [...] EAL: pthread_setaffinity_np failed PANIC in eal_thread_init_master(): cannot set affinity 7: [./master/app/testpmd() [0x47f629]] Bugzilla ID: 19 Signed-off-by: David Marchand --- lib/librte_eal/common/eal_common_options.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 3796dbf..7aad303 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1383,6 +1383,8 @@ static int xdigit2val(unsigned char c) /* default master lcore is the first one */ if (!master_lcore_parsed) { cfg->master_lcore = rte_get_next_lcore(-1, 0, 0); + if (cfg->master_lcore >= RTE_MAX_LCORE) + return -1; lcore_config[cfg->master_lcore].core_role = ROLE_RTE; } -- 1.8.3.1