From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3C041A0C45 for ; Fri, 8 Oct 2021 23:28:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 262D6410DB; Fri, 8 Oct 2021 23:28:55 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 39E13407FF; Fri, 8 Oct 2021 23:28:52 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10131"; a="225366540" X-IronPort-AV: E=Sophos;i="5.85,358,1624345200"; d="scan'208";a="225366540" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 14:28:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,358,1624345200"; d="scan'208";a="569157826" Received: from silpixa00400072.ir.intel.com ([10.237.222.213]) by fmsmga002.fm.intel.com with ESMTP; 08 Oct 2021 14:28:49 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, david.marchand@redhat.com, stable@dpdk.org Date: Fri, 8 Oct 2021 22:28:46 +0100 Message-Id: <1633728526-197782-1-git-send-email-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-stable] [PATCH] test/hash: fix buffer overflow X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "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 --- 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