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 A198843C12; Fri, 1 Mar 2024 18:17:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9456342FA9; Fri, 1 Mar 2024 18:17:04 +0100 (CET) Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) by mails.dpdk.org (Postfix) with ESMTP id 51F7E400D5; Fri, 1 Mar 2024 18:17:02 +0100 (CET) Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-21fa0ec227eso1145586fac.0; Fri, 01 Mar 2024 09:17:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709313421; x=1709918221; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=18kHu02PJUNotqnqEKPtNO8ITdIuOg9+0kX74JM2Ads=; b=jDe4Sr1oB2qcW8C++uz6byk7GKtY2XtZG2I1XcjzOGANkngBUSZPsF8stIipWeJjPI 1X6zbDeZrHN+FcOnEG6J22BoFR6BcUYyJ7vGCQcnEUAW7pXLRt7vAG2rKzNL7e208kKJ 4bI0oCoNFNy4Ga/ByTmvgOtOI53GpX/F234CJrRi70HmyclyoRH/yj0lBvpgQEGbCNfb pp/yRWd7vXknRA8NR7Fdwm/8cP07bVCCttbWjZA94LVO2dQgQ798jurmijjzIthXCl0j WCFlwznaI5l7MjRH9nuN0PNt/36RHLLvmrNOMVYsNL+5OG6FeL4cIuavHDe99dwhJiVo LlFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709313421; x=1709918221; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=18kHu02PJUNotqnqEKPtNO8ITdIuOg9+0kX74JM2Ads=; b=tTyZBCI/DaRAjkvS2WIQFQQqEZBxK9srIjrLwK5Vsrb2pAJBRWuShTTm7Zn3vCGqjZ OORPxFWSVsVGc6Qy2FN81wTVfGMJudyrvbzIVmXG8rsodlhA+87VCwieU0oqjIsh32ci eI6ngPzbkAgfk0T6mCngb61MV3K0XO1kJeAhBhLSyaIF9gNFKyXBNLSwKOH2dB7IoTuk HPRQ1YlpAFdSE9ncG2dh6Brukxz9BpvDkuU223fmu3OK/Y1lxWzEYjz7g4c1YSajXVP/ ttW/9pt5bqvOfPzAdzJV+MKUUsQLcCCb498tYI2r3Qq3CbbkmwWzbwaWJxx6vqg7wLKN WINw== X-Forwarded-Encrypted: i=1; AJvYcCXIFhZiJVfxZno4gtftRb97ppyvpB0WW/j7XlHVC0HPqQoAUeUt9LnH/+4HBTjQorASKaKHyE0ZuVulezNbTZM= X-Gm-Message-State: AOJu0YylyeBgw3ccFO5LmDzeaczss8/kwarTVdwdrf5VgkF/nJcIREm/ F9guUFrUgrVUPSIRPPE/ZqlkPxH6mO7XdLnvUrYVLD22+smWO55i/RXnEDVhxO45lwY/Rf1vZbr byxRim2WD6DPE63p/AUpFC2Pl3PY= X-Google-Smtp-Source: AGHT+IEl+lr31dlCFpDFdfyCiTIB8i1Vc7lCglm5VtyMOkucpFMq3xnUSsqOy60sNnX6osWa1tW6taHPpzl4pzTe/1c= X-Received: by 2002:a05:6870:8a08:b0:220:a23c:6786 with SMTP id p8-20020a0568708a0800b00220a23c6786mr2104164oaq.11.1709313421568; Fri, 01 Mar 2024 09:17:01 -0800 (PST) MIME-Version: 1.0 References: <20230706152626.476775-1-conor.fogarty@intel.com> In-Reply-To: <20230706152626.476775-1-conor.fogarty@intel.com> From: Vladimir Medvedkin Date: Fri, 1 Mar 2024 17:16:50 +0000 Message-ID: Subject: Re: [PATCH] hash: fix segfault by adding param name NULL check To: Conor Fogarty Cc: dev@dpdk.org, pablo.de.lara.guarch@intel.com, "Medvedkin, Vladimir" , stable@dpdk.org Content-Type: multipart/alternative; boundary="0000000000004d6c8b06129c8ba4" 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 --0000000000004d6c8b06129c8ba4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable +cc stable@ Acked-by: Vladimir Medvedkin =D1=87=D1=82, 6 =D0=B8=D1=8E=D0=BB. 2023=E2=80=AF=D0=B3. =D0=B2 16:26, Cono= r 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") > > Signed-off-by: Conor Fogarty > > --- > 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 =3D=3D NULL) || > (params->key_len =3D=3D 0)) { > rte_errno =3D 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 contac= t > the > sender and delete all copies. > > --=20 Regards, Vladimir --0000000000004d6c8b06129c8ba4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Acked-by: V= ladimir Medvedkin <vladi= mir.medvedkin@intel.com>
<= /div>
= =D1=87=D1=82, 6 =D0=B8=D1=8E=D0=BB. 2023=E2=80=AF=D0=B3. =D0=B2 16:26, Cono= r Fogarty <conor.fogarty@inte= l.com>:
A= dd 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&qu= ot;)

Signed-off-by: Conor Fogarty <conor.fogarty@intel.com>

---
Cc: pab= lo.de.lara.guarch@intel.com
---
=C2=A0lib/hash/rte_cuckoo_hash.c | 1 +
=C2=A01 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 *param= s)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Check for valid parameters */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((params->entries > RTE_HASH_ENTRIES_M= AX) ||
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (params->entries < RTE_HASH_BUCKET_ENTRIES) ||
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(params->name =3D=3D NULL) ||
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (params->key_len =3D=3D 0)) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 rte_errno =3D EINVA= L;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 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 s= ole
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.



--
Regards,
Vladimir
--0000000000004d6c8b06129c8ba4--