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 8D850A0540; Mon, 4 Jul 2022 12:34:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 26AA8410E5; Mon, 4 Jul 2022 12:34:45 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A766D40E09 for ; Mon, 4 Jul 2022 12:34:43 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 263M0aa1015540; Mon, 4 Jul 2022 03:34:43 -0700 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h2nhnn6jq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Jul 2022 03:34:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XoOatOxoCrYkTdKFgEbtkS8TFNPTbr1w54LBJhcM0gqnjyZ8rUv6nJgT1hqEg3oFtuO2zgoN7ux3CdpBhxBTf11gXZTL1DXqotKB5z5otmu8RpYdRNcPSM+WOXZa1CeR9JtBoyx5oXt9fFZ4RlFXFLTSfiAZDpQSM1WNnL9Tkoo8kZvPNYdwIDcvGz/YXJEOHHmsbz1YZ64Wq/MbIpCTu+MEUdHb2TrAhr8NXzBVZq+Vdk+zbddwrkMQCw6GDKezgppIGlDCHaDjhqjUf1Paixa16QPkteRWntKoMJbwwkXa4szG6IqWV9PHJstFHr8Ay9W1QJLy5AcShK190XjZqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2GjIz/6vakqy5y8ec4ztTNoE8DSKwVqdZeXYD+kvL0I=; b=cuYv0Do2NwJz9RT5ZQyl12rlQu0f8ftpfG5vKULCRUuNIODkcvSzy5SIfeeOwPAR1RLjd/vGK22QNapcJ+0sFihwIZuwVpN5VFvCh017cKMxblHkVQvpk7xiyMCO/JQEUDQRg2o+WMW0XdGn7iShMjCAw1FsjqUc/8DIn5PTQF5WT8YsesFi2XVLkeZqoiQbkDXlRPEd9uj6hi0Z0c/EgEVW1pbwLcCaspwGJZAZZTACkmSyLWnhgfkljeN+SzWqd8630BKisPnfmCAm/46Jgxg+6YCHitoeG7UkwJ71Fn/jl7pN9Zz9Yu8/k4tYGAZVCqGAdYywder0PYlHLuJt9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2GjIz/6vakqy5y8ec4ztTNoE8DSKwVqdZeXYD+kvL0I=; b=qR6mRMkx5sWEb+6+0YRUA1fCf+nSnTgrHUgKLG2MOdIZqBR8Zr/zG3fs8CMfrmCB/ZOo9YFOV4ZlY/HSDwMI8dWPfA+84HA3XXbnIy6L50xjrJ3Bgzqbuchg6Zkk43FXnWSdHHyhDppp7+hKl9jQSlrGVRrdmerb3p01r9r/Zc8= Received: from PH0PR18MB4491.namprd18.prod.outlook.com (2603:10b6:510:e6::13) by MWHPR18MB1487.namprd18.prod.outlook.com (2603:10b6:320:2b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.19; Mon, 4 Jul 2022 10:34:40 +0000 Received: from PH0PR18MB4491.namprd18.prod.outlook.com ([fe80::f9aa:4855:effe:83b9]) by PH0PR18MB4491.namprd18.prod.outlook.com ([fe80::f9aa:4855:effe:83b9%3]) with mapi id 15.20.5395.020; Mon, 4 Jul 2022 10:34:40 +0000 From: Akhil Goyal To: Gowrishankar Muthukrishnan , "dev@dpdk.org" , David Marchand , Thomas Monjalon CC: Fan Zhang , Brian Dooley , Anoob Joseph , Archana Muniganti , Jerin Jacob Kollanukkaran , Gowrishankar Muthukrishnan Subject: RE: [PATCH v3] examples/fips_validation: fix memory leak in sha test Thread-Topic: [PATCH v3] examples/fips_validation: fix memory leak in sha test Thread-Index: AQHYj4w9ieX4ikQsQkOd5ErcZa6AnK1uA77g Date: Mon, 4 Jul 2022 10:34:40 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 59ddb4bf-3536-42bb-f8f7-08da5da8cd3b x-ms-traffictypediagnostic: MWHPR18MB1487:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NJTV+dzU5SKl/cUPhPv/87v4JFFTS8dtGOOSztZCt1vxxqo8NbD8bc+XykSWlR4/oIsOrBPG2A+s69DCpaPAREv9zUWq6g3pGzD7dWIVWtCpj1AJYbhmv4Xh1OXWtr/b+it8O7NtrELg8weqbX9yD4W1yTyZb26VRYPMl+SLIHIH4pysZeR4f4gHofeJB+oUlGWOvzhJp+yMuzUFqhxbQnYuP6uTI60tX2oCT81uxPU+OAvS6k+yHo1fX+vIXRtTLMc5y5wbmgvFGTBxScxQO9pMbmmZjogi9rOI+4oSHv+suQus3AbT5e4pF94XtTU610QCtmRiHChfLYiQ79Zw50SLPs6+2XJhji81y515LyVWTHJCZ1q21LSRq81M6LBQBbbdpKoSVAQ3cwi2R8sXfw6mqp5P8pBPcs9cypdqdRK4etM8seDY3ybNge1GzYAAoh2YJcW3tmdlqwuygDDkI3zOk7lpltJK0pkkFKbZWiOQ/6CTuJlAPUebAaQbWdGs7OCII388cGKbsPgu5FqE2Up5wi2S6pQSCiWzyBlRo8y6Zd7Ioq4+nw71THpKyLf+b8ZJUxMFCwtAcLFrOWYio33iuP5qFmoCsNMJZpr4hU+DKOjSJYNHXByqGaJWiGIZ8Upk8XiU7/9miX8dDk/pBmueBoRz0mhwtmBTIXWCFE+GdYKtTuRIK51w9G2PdOHGS3UurzSo2eBHsHqri3Zs0IYaF5tl7GwJn6OW/7JZKUoes7Z8FrKX7GcspGeTggxMyH5lCi9o/E4YSV6ozrQQw8Pbqwv2t3CAu609BoTsaYzOfvnJZtAes8M7b28elsbdGRSV2zPU3In+QxHPLaVp2mxmadDMcgDcDz5Jb6tUO4Ip1X/HrD9gwLbFf2QftmmR x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR18MB4491.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(366004)(396003)(376002)(136003)(39860400002)(4326008)(478600001)(5660300002)(52536014)(38070700005)(8936002)(76116006)(122000001)(110136005)(54906003)(316002)(86362001)(33656002)(71200400001)(64756008)(66556008)(66446008)(8676002)(66476007)(66946007)(6506007)(26005)(83380400001)(186003)(9686003)(107886003)(41300700001)(38100700002)(2906002)(7696005)(55016003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?gPoQZCJJYf0LmEDCNTZyd44AYL/pWtX3/0MuA5op7+9ue8fpwPilLLTEMPvl?= =?us-ascii?Q?ImYYJSzIj1ByYEMWGujyt3VsvQ9xQx5gScAvjEB/IPH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q?FPFGoHCtESJdIm5B2OLuwGWCLk30bq6uklk34I/kHuLKEnMWCb/iugomAU6d?= =?us-ascii?Q?5f6j0GGwDSbHQjFm1M8NhLstP5CsmMl2TGNeqZW/U9lRrZvY/m7ag3VAfJcF?= =?us-ascii?Q?sn2Qb6JJjWr9VrosIU0bAgUxTwktR3lJgTPrfNtX4KYDkTfq1ykvUCV42DMX?= =?us-ascii?Q?VF51kY23ksIiOMBGXEZLhgZpYcptuen7XmGFqGc1HqrFKSLe88FcrgXxPLqe?= =?us-ascii?Q?lrV1tSirwYNolWgCLziH4G7JKKkev7D8NNLibS92JTZ7yspY0/FUa0IeOwm2?= =?us-ascii?Q?hkejoUB2vqUfKLQ+/pDw57XgUt0aaG4shf7oOMwUZ5cCM/kZa/LHQYQnOkT1?= =?us-ascii?Q?KC7V7dQSS795ylJ+V4eXhiLBQL/vVc9oLLFrQ0th2XUHsn3Yif1PQ1wtapR/?= =?us-ascii?Q?K29qDyxzFJADXtiPGwQOLSZWwF456zhfSaGE0ss2ZieglBtN0T1vS9ItOUD2?= =?us-ascii?Q?nhcjbBxp2WqOCiF03DI6AfaYvjnqvPJqnFE0Cl41eqA4gTjXkAppDMk4Esuu?= =?us-ascii?Q?79Yjw0TcYmBgcFoYmHHFaKDgyOTZfsq/ybhxDYA6Ci6N+EifJvcpjdvqMUv2?= =?us-ascii?Q?fsN8tOtcY+dgYAc2DEsM1pnwTifg2Ak6+/gmv/Dn?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR18MB4491.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59ddb4bf-3536-42bb-f8f7-08da5da8cd3b X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jul 2022 10:34:40.5182 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ayNFjSrCHIlEh4yviR9/mrUTPoolqhT5xdYI1jUaaQNCBp3UOwS70PicweQ3YpoO34CB7Ut8PrS9fbUgJpRmMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR18MB1487 X-Proofpoint-ORIG-GUID: pGROvXq0IIzk_JOLze9UDK99LRwdpx_G X-Proofpoint-GUID: pGROvXq0IIzk_JOLze9UDK99LRwdpx_G X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-04_09,2022-06-28_01,2022-06-22_01 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 > Subject: [PATCH v3] examples/fips_validation: fix memory leak in sha test >=20 > There is wrong size used for allocation of digest buffer which in > some cases cause memory corruption. Also, fixed places where memory > leak is observed. This fix would enable sha 384 and 512 NIST vectors > be supported fully. Fixes: c9819d389b4b ("examples/fips_validation: add parsing for SHA") ++David/Thomas >=20 > Signed-off-by: Gowrishankar Muthukrishnan > --- > v3: > - addes fixes for suggestions in v2. > --- > doc/guides/sample_app_ug/fips_validation.rst | 2 +- > examples/fips_validation/fips_validation_sha.c | 11 +++++++++-- > examples/fips_validation/main.c | 1 + > 3 files changed, 11 insertions(+), 3 deletions(-) >=20 > diff --git a/doc/guides/sample_app_ug/fips_validation.rst > b/doc/guides/sample_app_ug/fips_validation.rst > index 4b68226665..6f4bd34726 100644 > --- a/doc/guides/sample_app_ug/fips_validation.rst > +++ b/doc/guides/sample_app_ug/fips_validation.rst > @@ -63,7 +63,7 @@ ACVP > * AES-CMAC (128,192,256) - AFT > * AES-XTS (128,256) - AFT > * HMAC (SHA1, SHA224, SHA256, SHA384, SHA512) > - * SHA (1,256) - AFT, MCT > + * SHA (1, 256, 384, 512) - AFT, MCT >=20 >=20 > Application Information > diff --git a/examples/fips_validation/fips_validation_sha.c > b/examples/fips_validation/fips_validation_sha.c > index a2928618d7..dff552586f 100644 > --- a/examples/fips_validation/fips_validation_sha.c > +++ b/examples/fips_validation/fips_validation_sha.c > @@ -229,13 +229,20 @@ parse_test_sha_json_algorithm(void) > for (i =3D 0; i < RTE_DIM(phsc); i++) { > if (info.interim_info.sha_data.algo =3D=3D phsc[i].algo) { > vec.cipher_auth.digest.len =3D atoi(phsc[i].str); > - vec.cipher_auth.digest.val =3D calloc(0, > vec.cipher_auth.digest.len * 8); > + free(vec.cipher_auth.digest.val); > + vec.cipher_auth.digest.val =3D calloc(1, > vec.cipher_auth.digest.len); > + if (vec.cipher_auth.digest.val =3D=3D NULL) > + return -1; > + > break; > } > } >=20 > - if (i =3D=3D RTE_DIM(phsc)) > + if (i =3D=3D RTE_DIM(phsc)) { > + free(vec.cipher_auth.digest.val); > + vec.cipher_auth.digest.val =3D NULL; > return -1; > + } >=20 > return 0; > } > diff --git a/examples/fips_validation/main.c b/examples/fips_validation/m= ain.c > index 6d52048b5c..8bd5a66889 100644 > --- a/examples/fips_validation/main.c > +++ b/examples/fips_validation/main.c > @@ -2099,6 +2099,7 @@ fips_test_one_json_file(void) > json_info.json_vector_set =3D > json_array_get(json_info.json_root, vector_set_idx); > fips_test_one_vector_set(); > json_array_append_new(json_info.json_write_root, > json_info.json_write_set); > + json_incref(json_info.json_write_set); > } >=20 > json_dumpf(json_info.json_write_root, info.fp_wr, JSON_INDENT(4)); > -- > 2.25.1