DPDK patches and discussions
 help / color / mirror / Atom feed
From: Akhil Goyal <gakhil@marvell.com>
To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	David Marchand <david.marchand@redhat.com>,
	Thomas Monjalon <thomas@monjalon.net>
Cc: Fan Zhang <roy.fan.zhang@intel.com>,
	Brian Dooley <brian.dooley@intel.com>,
	Anoob Joseph <anoobj@marvell.com>,
	Archana Muniganti <marchana@marvell.com>,
	Jerin Jacob Kollanukkaran <jerinj@marvell.com>,
	Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Subject: RE: [PATCH v3] examples/fips_validation: fix memory leak in sha test
Date: Mon, 4 Jul 2022 10:34:40 +0000	[thread overview]
Message-ID: <PH0PR18MB449175964E30FBE8C4F4C9C3D8BE9@PH0PR18MB4491.namprd18.prod.outlook.com> (raw)
In-Reply-To: <b7ac7db51e01301b70899ae6dcff225952a7f37c.1656928437.git.gmuthukrishn@marvell.com>

> Subject: [PATCH v3] examples/fips_validation: fix memory leak in sha test
> 
> 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
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
> 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


  reply	other threads:[~2022-07-04 10:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-02 14:51 [PATCH v1] " Gowrishankar Muthukrishnan
2022-07-02 14:58 ` [PATCH v2] " Gowrishankar Muthukrishnan
2022-07-04  7:48   ` David Marchand
2022-07-04  7:50     ` [EXT] " Akhil Goyal
2022-07-04  8:26       ` Thomas Monjalon
2022-07-04  8:18     ` Gowrishankar Muthukrishnan
2022-07-02 18:44 ` Gowrishankar Muthukrishnan
2022-07-04  7:00   ` Akhil Goyal
2022-07-04  9:55   ` [PATCH v3] " Gowrishankar Muthukrishnan
2022-07-04 10:34     ` Akhil Goyal [this message]
2022-07-04 17:32       ` Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH0PR18MB449175964E30FBE8C4F4C9C3D8BE9@PH0PR18MB4491.namprd18.prod.outlook.com \
    --to=gakhil@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=brian.dooley@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=gmuthukrishn@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=marchana@marvell.com \
    --cc=roy.fan.zhang@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).