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 BCD93A0093; Sat, 2 Jul 2022 16:59:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F5CC40E50; Sat, 2 Jul 2022 16:59:01 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 8B4B140E03 for ; Sat, 2 Jul 2022 16:58:59 +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 262ETkgj032643; Sat, 2 Jul 2022 07:58:58 -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=w2AUPThYaHw0zE4wMtUUmFpANUjbCGJB3FioQk+XZUk=; b=RodnvAAlv49ULE+hVeqs3q5cu18p8MsBFRcOsJRH54xX1kKLIgPy2yqmka+XXHh/rLqD 5TjNjNwHdE6AI7qsaNW0Hezq/Kx8ZV4B4kQouvJJijyHDumEqy+WB+ZYVZ2Bv/uTGiNj QzH8FE8WXnkSJqGLsQeB5zpdYTXXU83QDSoO8ATpNxwiwOpf1UNlu0pDM/JdRt62Nk5g b9CUaqfVs7tqKktbUFG/Hy2T/iIu9460HuV6QIbUOIa2k05gJxvzTjFGwq3jt0yjZWRd avQOI3djxXgiz9FKlFkDjXvCcljcqAYcTsARxft3huypdLdiw4yHUtX9UIW+tOt3r/Y5 vA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3h2kcr8j07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 02 Jul 2022 07:58:58 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sat, 2 Jul 2022 07:58:56 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Sat, 2 Jul 2022 07:58:56 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 8E14A3F708A; Sat, 2 Jul 2022 07:58:54 -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: Sat, 2 Jul 2022 20:28:50 +0530 Message-ID: <40cf83ba9d410a387eccfd93c04d9035f71227f2.1656773832.git.gmuthukrishn@marvell.com> 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: T9-fErmz1Y1hQ4TgOJ1Tw8aG-bllQk-8 X-Proofpoint-ORIG-GUID: T9-fErmz1Y1hQ4TgOJ1Tw8aG-bllQk-8 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_11,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 --- v2: - doc update to support 384 and 512 sha. --- 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