Skip to contentSkip to conversation

hash: fix segfault by adding param name NULL check

PATCH Applied Conor Fogarty 3 participants 3 messages Jul 6, 2023 – Jun 14, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hash: fix segfault by adding param name NULL check

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

---
Cc: [email protected]

---
 lib/hash/rte_cuckoo_hash.c | 1 +
 1 file changed, 1 insertion(+)
lib/hash/rte_cuckoo_hash.c +1 -0
index d92a903bb3..0aab091c4d 100644
@@ -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");
Signature · 13 lines
2.25.1

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.
Acked-by on v1 1/1
#1 lore raw

+cc stable@

чт, 6 июл. 2023 г. в 16:26, Conor Fogarty <[email protected]>:

Quoted 46 lines

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

---
Cc: [email protected]

---
 lib/hash/rte_cuckoo_hash.c | 1 +
 1 file changed, 1 insertion(+)
lib/hash/rte_cuckoo_hash.c +1 -0
index d92a903bb3..0aab091c4d 100644
@@ -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");
--
2.25.1

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263

This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.

Signature · 2 lines
Regards,
Vladimir
Acked-by Vladimir Medvedkin on v1 1/1 Applied
#2 lore raw
In reply to Conor Fogarty
Quoted 6 lines · Conor Fogarty

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")
Quoted 2 lines

Applied, thanks.

Signature · 1 line
David Marchand