DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] table: fix a crash during key8 and key32 overload
@ 2015-03-23 15:09 Maciej Gajdzica
  2015-03-23 15:20 ` Dumitrescu, Cristian
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej Gajdzica @ 2015-03-23 15:09 UTC (permalink / raw)
  To: 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 <maciejx.t.gajdzica@intel.com>
---
 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;
 				}
 
-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH] table: fix a crash during key8 and key32 overload
@ 2015-03-23 15:10 Maciej Gajdzica
  0 siblings, 0 replies; 5+ messages in thread
From: Maciej Gajdzica @ 2015-03-23 15:10 UTC (permalink / raw)
  To: 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 <maciejx.t.gajdzica@intel.com>
---
 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;
 				}
 
-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-27 11:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23 15:09 [dpdk-dev] [PATCH] table: fix a crash during key8 and key32 overload Maciej Gajdzica
2015-03-23 15:20 ` Dumitrescu, Cristian
2015-03-23 15:22   ` Walukiewicz, Miroslaw
2015-03-27 11:19   ` Thomas Monjalon
2015-03-23 15:10 Maciej Gajdzica

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).