From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 0DC06968; Wed, 20 Sep 2017 09:49:14 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 00:49:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,420,1500966000"; d="scan'208";a="137406243" Received: from unknown (HELO Sent) ([10.103.102.77]) by orsmga002.jf.intel.com with SMTP; 20 Sep 2017 00:49:10 -0700 Received: by Sent (sSMTP sendmail emulation); Wed, 20 Sep 2017 09:47:39 +0200 From: Slawomir Mrozowicz To: john.mcnamara@intel.com Cc: dev@dpdk.org, Slawomir Mrozowicz , ian.betts@intel.com, stable@dpdk.org Date: Wed, 20 Sep 2017 09:47:34 +0200 Message-Id: <1505893654-25460-1-git-send-email-slawomirx.mrozowicz@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] examples/performance-thread: fix out-of-bounds read 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, 20 Sep 2017 07:49:15 -0000 Overrunning array schedcore of 128 8-byte elements at element index 128 using index lcore_id. Fixed by correct check index lcoreid condition and change type of lcoreid to unsigned. Coverity issue: 143459 Fixes: 116819b9ed0d ("examples/performance-thread: add lthread subsystem") Cc: ian.betts@intel.com Cc: stable@dpdk.org Signed-off-by: Slawomir Mrozowicz --- examples/performance-thread/common/lthread.h | 2 +- examples/performance-thread/common/lthread_sched.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/performance-thread/common/lthread.h b/examples/performance-thread/common/lthread.h index 5c2c1a5f0..0cde5919b 100644 --- a/examples/performance-thread/common/lthread.h +++ b/examples/performance-thread/common/lthread.h @@ -87,7 +87,7 @@ int _lthread_desched_sleep(struct lthread *lt); void _lthread_free(struct lthread *lt); -struct lthread_sched *_lthread_sched_get(int lcore_id); +struct lthread_sched *_lthread_sched_get(unsigned int lcore_id); struct lthread_stack *_stack_alloc(void); diff --git a/examples/performance-thread/common/lthread_sched.c b/examples/performance-thread/common/lthread_sched.c index 98291478e..3484387b4 100644 --- a/examples/performance-thread/common/lthread_sched.c +++ b/examples/performance-thread/common/lthread_sched.c @@ -562,11 +562,14 @@ void lthread_run(void) * Return the scheduler for this lcore * */ -struct lthread_sched *_lthread_sched_get(int lcore_id) +struct lthread_sched *_lthread_sched_get(unsigned int lcore_id) { - if (lcore_id > LTHREAD_MAX_LCORES) - return NULL; - return schedcore[lcore_id]; + struct lthread_sched *res = NULL; + + if (lcore_id < LTHREAD_MAX_LCORES) + res = schedcore[lcore_id]; + + return res; } /* -- 2.11.0