From patchwork Sun Feb 22 18:40:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 3586 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 0A68CB400; Sun, 22 Feb 2015 19:41:00 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 0BF30B3FF for ; Sun, 22 Feb 2015 19:40:57 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 22 Feb 2015 10:33:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,626,1418112000"; d="scan'208";a="689110285" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga002.jf.intel.com with ESMTP; 22 Feb 2015 10:40:56 -0800 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.247]) by IRSMSX102.ger.corp.intel.com ([169.254.2.69]) with mapi id 14.03.0195.001; Sun, 22 Feb 2015 18:40:54 +0000 From: "Richardson, Bruce" To: Igor Ryzhov Thread-Topic: [PATCH] lpm: fix overflow issue Thread-Index: AQHQTimsT6rbLqrfD0ik46rtD3zyCpz9Adlk Date: Sun, 22 Feb 2015 18:40:53 +0000 Message-ID: <19E2A698-96BB-4CFE-9BCE-50AFB815D24B@intel.com> References: <1424438206-29526-1-git-send-email-iryzhov@nfware.com>, In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] lpm: fix overflow issue 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Sorry I missed this Friday. I'll look at it shortly. On 21 Feb 2015, at 22:56, Igor Ryzhov > wrote: Hello again. Will anybody review this patch? This is really critical issue, because it can lead to memory corruption and break any program using LPM. CCing this to Bruce Richardson, because he is maintainer of LPM. Regards, Igor Ryzhov On Fri, Feb 20, 2015 at 4:16 PM, Igor Ryzhov > wrote: LPM table overflow may occur if table is full and added rule has the biggest depth that already have some rules. Signed-off-by: Igor Ryzhov > --- lib/librte_lpm/rte_lpm.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.9.3 (Apple Git-50) -- Regards, Igor Ryzhov diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 983e04b..cc51210 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -298,6 +298,9 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, return rule_index; } } + + if (rule_index == lpm->max_rules) + return -ENOSPC; } else { /* Calculate the position in which the rule will be stored. */ rule_index = 0;