From patchwork Mon Mar 23 15:09:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Gajdzica X-Patchwork-Id: 4112 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 49A4911C5; Mon, 23 Mar 2015 16:13:33 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 63621106B for ; Mon, 23 Mar 2015 16:13:31 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 23 Mar 2015 08:13:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,452,1422950400"; d="scan'208";a="702843727" Received: from unknown (HELO Sent) ([10.217.248.233]) by orsmga002.jf.intel.com with SMTP; 23 Mar 2015 08:13:28 -0700 Received: by Sent (sSMTP sendmail emulation); Mon, 23 Mar 2015 16:09:15 +0100 From: Maciej Gajdzica To: dev@dpdk.org Date: Mon, 23 Mar 2015 16:09:07 +0100 Message-Id: <1427123347-16200-1-git-send-email-maciejx.t.gajdzica@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] table: fix a crash during key8 and key32 overload 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" hash_key8_ext and hash_key32_ext tables allocate cache entries to support table overload cases. The crash can occur when cache entry is free after use. The problem is with computing the index of the free cache entry. The same case for key16 was fixed with earlier patch. Signed-off-by: Maciej Gajdzica Reviewed-by: Mirek Walukiewicz --- lib/librte_table/rte_table_hash_key32.c | 5 ++--- lib/librte_table/rte_table_hash_key8.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/librte_table/rte_table_hash_key32.c b/lib/librte_table/rte_table_hash_key32.c index da0ce6a..6790594 100644 --- a/lib/librte_table/rte_table_hash_key32.c +++ b/lib/librte_table/rte_table_hash_key32.c @@ -540,9 +540,8 @@ rte_table_hash_entry_delete_key32_ext( memset(bucket, 0, sizeof(struct rte_bucket_4_32)); - bucket_index = (bucket - - ((struct rte_bucket_4_32 *) - f->memory)) - f->n_buckets; + bucket_index = (((uint8_t *)bucket - + (uint8_t *)f->memory)/f->bucket_size) - f->n_buckets; f->stack[f->stack_pos++] = bucket_index; } diff --git a/lib/librte_table/rte_table_hash_key8.c b/lib/librte_table/rte_table_hash_key8.c index 443ca7d..6803eb2 100644 --- a/lib/librte_table/rte_table_hash_key8.c +++ b/lib/librte_table/rte_table_hash_key8.c @@ -528,9 +528,8 @@ rte_table_hash_entry_delete_key8_ext( memset(bucket, 0, sizeof(struct rte_bucket_4_8)); - bucket_index = (bucket - - ((struct rte_bucket_4_8 *) - f->memory)) - f->n_buckets; + bucket_index = (((uint8_t *)bucket - + (uint8_t *)f->memory)/f->bucket_size) - f->n_buckets; f->stack[f->stack_pos++] = bucket_index; }