From patchwork Thu Jul 6 15:26:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Fogarty X-Patchwork-Id: 129343 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5EB4F42DE9; Thu, 6 Jul 2023 17:26:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA3D1410FA; Thu, 6 Jul 2023 17:26:34 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id DF6A840A79 for ; Thu, 6 Jul 2023 17:26:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688657193; x=1720193193; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=gm5WkLy3KhO/blCWZNdiRdZThR0S2glfOa9LQNcboco=; b=G9wI4I2BUkzQnVpcLNOOyOYwlLD8wv0pBbHFOtGEmQB8ammA90irgi0v d90Lj6EzHR6K2BuCNgyId9oWLBsYjkdt7NznBlU01eF3Nx33DlyMtHsjr bpLiIT/TUrdPk/bxO4i/Mesp9qx7VobKl9xcyFGtca0ncJS5vVxFdjuD8 3WUHfDeNohvCQD+Lgje1iSx4/XlMBNXKkUy/cZaUL/QRR4ZmLjG4yXsMQ 977mAl/dps6eJLTuPAh+E2uutWvqpDYKEqfzpii5+mY1EE4UAwACVFZpF 9jZQ+5ifITJmejPghipsPjzkjm74GcNQJ0LmvkAOUSty5Mmr1WKd/IqDH A==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="394390572" X-IronPort-AV: E=Sophos;i="6.01,185,1684825200"; d="scan'208";a="394390572" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 08:26:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="722822326" X-IronPort-AV: E=Sophos;i="6.01,185,1684825200"; d="scan'208";a="722822326" Received: from silpixa00400784.ir.intel.com ([10.237.213.48]) by fmsmga007.fm.intel.com with ESMTP; 06 Jul 2023 08:26:29 -0700 From: Conor Fogarty To: dev@dpdk.org Cc: Conor Fogarty , pablo.de.lara.guarch@intel.com Subject: [PATCH] hash: fix segfault by adding param name NULL check Date: Thu, 6 Jul 2023 16:26:26 +0100 Message-Id: <20230706152626.476775-1-conor.fogarty@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add NULL pointer check to params->name, which is later copied into the hash datastructure. Without this check the code segfaults on the strlcpy() of a NULL pointer. Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation") Signed-off-by: Conor Fogarty Acked-by: Vladimir Medvedkin --- Cc: pablo.de.lara.guarch@intel.com --- lib/hash/rte_cuckoo_hash.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index d92a903bb3..0aab091c4d 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -166,6 +166,7 @@ rte_hash_create(const struct rte_hash_parameters *params) /* Check for valid parameters */ if ((params->entries > RTE_HASH_ENTRIES_MAX) || (params->entries < RTE_HASH_BUCKET_ENTRIES) || + (params->name == NULL) || (params->key_len == 0)) { rte_errno = EINVAL; RTE_LOG(ERR, HASH, "rte_hash_create has invalid parameters\n");