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 5FCDDA0540; Mon, 4 Jul 2022 11:55:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 44F0D410E5; Mon, 4 Jul 2022 11:55:13 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 7801640E09 for ; Mon, 4 Jul 2022 11:55:11 +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 263M0aVs015540; Mon, 4 Jul 2022 02:55:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=sp4UG1zyU0W0Iq4jhcQFPIa4lidvjTjXN3GQxT7J84o=; b=UMUeuP/kh02glz+oKj62AqRakiIvBwLgJ+MEC81yGxqF4EIcXOz/Ev8twj+0iSMoyj9e aZp5Nvc5sUmZDXoO+fdx7U0AbnTMzfoFP0XfhutpWk8RloeXwcwyS6aOwTj7qW3/RiuK w/kCld+AVvpdPdmeLia+/DAfSgEB56mM8D7sB1/+AVmcCBSVY435HRCzmDR8OX/HaJ4o xewn1zjjPLVWr6C4EpILkV9qAI4NB2yrcW2RCj7InNSQ5onmTDVEftPXORIBTS+qZnlW e/kTp84qGarlO6qE3q38aN3uWH/4gxBQHmnNTqG+am/6SJJScIk9eImY/9HEBF3Gbyde lQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h2nhnn2m3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 04 Jul 2022 02:55:10 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 4 Jul 2022 02:55:08 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 4 Jul 2022 02:55:08 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id EFF9A3F7096; Mon, 4 Jul 2022 02:55:05 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Akhil Goyal , Fan Zhang , Brian Dooley , Anoob Joseph , Archana Muniganti , Jerin Jacob , Gowrishankar Muthukrishnan Subject: [PATCH v3] examples/fips_validation: fix memory leak in sha test Date: Mon, 4 Jul 2022 15:25:03 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: OCCJSredozX7rcCgNUIBYP4pGYyxPkh3 X-Proofpoint-GUID: OCCJSredozX7rcCgNUIBYP4pGYyxPkh3 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 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. 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(-) 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 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 = 0; i < RTE_DIM(phsc); i++) { if (info.interim_info.sha_data.algo == phsc[i].algo) { vec.cipher_auth.digest.len = atoi(phsc[i].str); - vec.cipher_auth.digest.val = calloc(0, vec.cipher_auth.digest.len * 8); + free(vec.cipher_auth.digest.val); + vec.cipher_auth.digest.val = calloc(1, vec.cipher_auth.digest.len); + if (vec.cipher_auth.digest.val == NULL) + return -1; + break; } } - if (i == RTE_DIM(phsc)) + if (i == RTE_DIM(phsc)) { + free(vec.cipher_auth.digest.val); + vec.cipher_auth.digest.val = NULL; return -1; + } return 0; } diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.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 = 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); } json_dumpf(json_info.json_write_root, info.fp_wr, JSON_INDENT(4)); -- 2.25.1