From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 254E49FE; Wed, 20 Sep 2017 10:24:54 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 01:24:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,420,1500966000"; d="scan'208";a="1174065021" Received: from unknown (HELO Sent) ([10.103.102.77]) by orsmga001.jf.intel.com with SMTP; 20 Sep 2017 01:24:51 -0700 Received: by Sent (sSMTP sendmail emulation); Wed, 20 Sep 2017 10:21:12 +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 10:21:10 +0200 Message-Id: <1505895670-25808-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 08:24:55 -0000 Overrunning array per_lcore_this_sched->current_lthread->tls->data of 1024 8-byte elements at element index 1024 using index k. Fixed by correct check k condition. Coverity issue: 143463 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_tls.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/performance-thread/common/lthread_tls.c b/examples/performance-thread/common/lthread_tls.c index 47505f2d4..4ae3c6c03 100644 --- a/examples/performance-thread/common/lthread_tls.c +++ b/examples/performance-thread/common/lthread_tls.c @@ -198,11 +198,12 @@ void _lthread_tls_destroy(struct lthread *lt) void *lthread_getspecific(unsigned int k) { + void *res = NULL; - if (k > LTHREAD_MAX_KEYS) - return NULL; + if (k < LTHREAD_MAX_KEYS) + res = THIS_LTHREAD->tls->data[k]; - return THIS_LTHREAD->tls->data[k]; + return res; } /* -- 2.11.0