DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] test/hash: fix buffer overflow
@ 2021-10-08 21:28 Vladimir Medvedkin
  2021-10-11 11:03 ` David Marchand
  2021-10-13 19:27 ` [dpdk-dev] [PATCH v2] " Vladimir Medvedkin
  0 siblings, 2 replies; 16+ messages in thread
From: Vladimir Medvedkin @ 2021-10-08 21:28 UTC (permalink / raw)
  To: dev; +Cc: yipeng1.wang, sameh.gobriel, bruce.richardson, david.marchand, stable

This patch fixes buffer overflow reported by ASAN,
please reference https://bugs.dpdk.org/show_bug.cgi?id=818

Some tests for the rte_hash table use the rte_jhash_32b() as
the hash function. This hash function interprets the length
argument in units of 4 bytes.

This patch divides configured key length by 4 in cases when
rte_jhash_32b() is used.

Bugzilla ID: 818
Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 app/test/test_hash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index bd4d0cb..650d977 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -1617,7 +1617,8 @@ test_hash_add_delete_jhash2(void)
 	int32_t pos1, pos2;
 
 	hash_params_ex.name = "hash_test_jhash2";
-	hash_params_ex.key_len = 4;
+	/* Set the key_len divided by 4 due to using rte_jhash_32b() */
+	hash_params_ex.key_len = 4 / sizeof(uint32_t);
 	hash_params_ex.hash_func = (rte_hash_function)rte_jhash_32b;
 
 	handle = rte_hash_create(&hash_params_ex);
@@ -1656,7 +1657,8 @@ test_hash_add_delete_2_jhash2(void)
 	int32_t pos1, pos2;
 
 	hash_params_ex.name = "hash_test_2_jhash2";
-	hash_params_ex.key_len = 8;
+	/* Set the key_len divided by 4 due to using rte_jhash_32b() */
+	hash_params_ex.key_len = 8 / sizeof(uint32_t);
 	hash_params_ex.hash_func = (rte_hash_function)rte_jhash_32b;
 
 	handle = rte_hash_create(&hash_params_ex);
-- 
2.7.4


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

end of thread, other threads:[~2021-10-21  7:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08 21:28 [dpdk-dev] [PATCH] test/hash: fix buffer overflow Vladimir Medvedkin
2021-10-11 11:03 ` David Marchand
2021-10-13 19:26   ` Medvedkin, Vladimir
2021-10-14  7:04     ` David Marchand
2021-10-14 17:46       ` Medvedkin, Vladimir
2021-10-13 19:27 ` [dpdk-dev] [PATCH v2] " Vladimir Medvedkin
2021-10-14  8:34   ` David Marchand
2021-10-14 17:47     ` Medvedkin, Vladimir
2021-10-14 17:48   ` [dpdk-dev] [PATCH v3] " Vladimir Medvedkin
2021-10-15  9:33     ` David Marchand
2021-10-15 13:02       ` Medvedkin, Vladimir
2021-10-19  7:02         ` David Marchand
2021-10-19 15:57           ` Medvedkin, Vladimir
2021-10-20 19:54             ` David Marchand
2021-10-20 20:49               ` Wang, Yipeng1
2021-10-21  7:40     ` David Marchand

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).