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 F3314A0093; Sat, 2 Jul 2022 20:44:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 951C141132; Sat, 2 Jul 2022 20:44:12 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 75EEE40E50 for ; Sat, 2 Jul 2022 20:44:10 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 262FcI9p028068; Sat, 2 Jul 2022 11:44:09 -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=aNVP6bCar54C2xtIEdx/Kg2lvrxh663CrqUAiNBDKGM=; b=QTBkVGxYncHL4lbDdc5rITob1fc8cVawQstbdAU6W0lfinXgVVVRqXFg8n9Q0hikffWj nC229ozoqIM/OFCxglRGdQ4LfAwdn/fLZdnRe297ikzmzQZdyoEhUdpBp2pZSihVBkns UrbvbedEgwsB4xgCNggTBGq1KjKBfSX4CvB1WFZHQ1GllGbly2CELXuhiMx3njOyzdFl ZTOO7Oeat9Si5lJQRB4nExkynxaSL7d2sk5YwXCRYkrCBc159SfKpTlunfuw/UBq/yWx MqzDOMMpK2l1RAFAwoMt57ZwcdSs0whEvsNv8qsk/j2aCsOIAWCoiouo0ph58RxTOGb6 dg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3h2kcr8wr6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 02 Jul 2022 11:44:09 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 2 Jul 2022 11:44:07 -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; Sat, 2 Jul 2022 11:44:07 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id A28993F7084; Sat, 2 Jul 2022 11:44:04 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Akhil Goyal , Fan Zhang , Brian Dooley , Anoob Joseph , Archana Muniganti , Jerin Jacob , Gowrishankar Muthukrishnan Subject: [PATCH v2] examples/fips_validation: fix memory leak in sha test Date: Sun, 3 Jul 2022 00:14:01 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <2acc661bc1b574166e599957c805d70eee0d3a42.1656773321.git.gmuthukrishn@marvell.com> References: <2acc661bc1b574166e599957c805d70eee0d3a42.1656773321.git.gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: ca44VBNqhk013ButeML5o0AUZiXSGCqc X-Proofpoint-ORIG-GUID: ca44VBNqhk013ButeML5o0AUZiXSGCqc 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-02_15,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. Fixes: 93d797d94f1 ("examples/fips_validation: add parsing for sha") Signed-off-by: Gowrishankar Muthukrishnan --- Depends-on: series-23828 ("example/fips_validation: add xts and sha json parsing") --- doc/guides/sample_app_ug/fips_validation.rst | 2 +- examples/fips_validation/fips_validation_sha.c | 10 ++++++++-- examples/fips_validation/main.c | 1 + 3 files changed, 10 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..538cb6647a 100644 --- a/examples/fips_validation/fips_validation_sha.c +++ b/examples/fips_validation/fips_validation_sha.c @@ -229,13 +229,19 @@ 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); + if (vec.cipher_auth.digest.val) + free(vec.cipher_auth.digest.val); + + vec.cipher_auth.digest.val = calloc(1, vec.cipher_auth.digest.len); 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