From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A0C29374C for ; Wed, 27 Apr 2016 13:23:48 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 27 Apr 2016 04:23:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,541,1455004800"; d="scan'208";a="963751023" Received: from gklab-246-018.igk.intel.com (HELO stargo) ([10.217.246.18]) by orsmga002.jf.intel.com with SMTP; 27 Apr 2016 04:23:45 -0700 Received: by stargo (sSMTP sendmail emulation); Wed, 27 Apr 2016 13:29:26 +0200 From: Slawomir Mrozowicz To: david.marchand@6wind.com Cc: dev@dpdk.org, Slawomir Mrozowicz Date: Wed, 27 Apr 2016 13:29:22 +0200 Message-Id: <1461756562-5824-1-git-send-email-slawomirx.mrozowicz@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH v2] eal: out-of-bounds write X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2016 11:23:49 -0000 Fix issue reported by Coverity. Coverity ID 13282: Out-of-bounds write overrun-local: Overrunning array mcfg->memseg of 256 44-byte elements at element index 257 using index j. Fixes: af75078fece3 ("first public release") Signed-off-by: Slawomir Mrozowicz --- lib/librte_eal/linuxapp/eal/eal_memory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 5b9132c..715bd52 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1333,8 +1333,11 @@ rte_eal_hugepage_init(void) if (new_memseg) { j += 1; - if (j == RTE_MAX_MEMSEG) + if (j >= RTE_MAX_MEMSEG) { + RTE_LOG(ERR, EAL, + "Failed: memseg reached RTE_MAX_MEMSEG\n"); break; + } mcfg->memseg[j].phys_addr = hugepage[i].physaddr; mcfg->memseg[j].addr = hugepage[i].final_va; -- 1.9.1