[v2] aesni_mb: fix out-of-bounds access

Message ID 20190617143129.7106-1-roy.fan.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series [v2] aesni_mb: fix out-of-bounds access |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation fail Compilation issues

Commit Message

Fan Zhang June 17, 2019, 2:31 p.m. UTC
  This patch fixes the out-of-bounds coverity issue by adding
missed algorithms to the array.

Coverity issue: 337683

Fixes: c68d7aa354f6 ("crypto/aesni_mb: use architecture independent macros")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
  

Comments

Akhil Goyal June 18, 2019, 1:36 p.m. UTC | #1
Hi Fan,

> 
> This patch fixes the out-of-bounds coverity issue by adding
> missed algorithms to the array.
> 
> Coverity issue: 337683
> 
> Fixes: c68d7aa354f6 ("crypto/aesni_mb: use architecture independent macros")
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---
>  drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h | 17
> ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
> b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
> index 4d439360f..dda78d989 100644
> --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
> +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
> @@ -41,6 +41,14 @@ static const unsigned auth_blocksize[] = {
>  		[SHA_512]	= 128,
>  		[AES_XCBC]	= 16,
>  		[AES_CCM]	= 16,
> +		[AES_CMAC]	= 16,
> +		[AES_GMAC]	= 16,
> +		[AES_GCM]	= 16,
> +		[PLAIN_SHA1]	= 64,
> +		[PLAIN_SHA_224]	= 64,
> +		[PLAIN_SHA_256]	= 64,
> +		[PLAIN_SHA_384]	= 128,
> +		[PLAIN_SHA_512]	= 128
>  };
> 
>  /**
> @@ -65,7 +73,13 @@ static const unsigned
> auth_truncated_digest_byte_lengths[] = {
>  		[AES_XCBC]	= 12,
>  		[AES_CMAC]	= 12,
>  		[AES_CCM]	= 8,
> -		[NULL_HASH]	= 0
> +		[NULL_HASH]	= 0,
> +		[AES_GMAC]	= 16,
> +		[PLAIN_SHA1]	= 20,
> +		[PLAIN_SHA_224]	= 28,
> +		[PLAIN_SHA_256]	= 32,
> +		[PLAIN_SHA_384]	= 48,
> +		[PLAIN_SHA_512]	= 64
>  };
> 
>  /**
> @@ -90,6 +104,7 @@ static const unsigned auth_digest_byte_lengths[] = {
>  		[SHA_512]	= 64,
>  		[AES_XCBC]	= 16,
>  		[AES_CMAC]	= 16,
> +		[AES_CCM]	= 16,
>  		[AES_GMAC]	= 12,
>  		[NULL_HASH]	= 0,
>  		[PLAIN_SHA1]	= 20,
> --
> 2.14.5

Patchworks say that there is a compilation issue in this patch.

Could you please check.

Thanks,
Akhil
  
De Lara Guarch, Pablo June 18, 2019, 4:34 p.m. UTC | #2
Hi Fan,

> -----Original Message-----
> From: Zhang, Roy Fan
> Sent: Monday, June 17, 2019 3:31 PM
> To: dev@dpdk.org
> Cc: akhil.goyal@nxp.com; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>
> Subject: [PATCH v2] aesni_mb: fix out-of-bounds access
> 
> This patch fixes the out-of-bounds coverity issue by adding missed
> algorithms to the array.
> 
> Coverity issue: 337683
> 
> Fixes: c68d7aa354f6 ("crypto/aesni_mb: use architecture independent
> macros")
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---
>  drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h | 17
> ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
> b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
> index 4d439360f..dda78d989 100644
> --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
> +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
> @@ -41,6 +41,14 @@ static const unsigned auth_blocksize[] = {
>  		[SHA_512]	= 128,
>  		[AES_XCBC]	= 16,
>  		[AES_CCM]	= 16,
> +		[AES_CMAC]	= 16,
> +		[AES_GMAC]	= 16,
> +		[AES_GCM]	= 16,

As Akhil has pointed out, there is a compilation error,
because there is no AES_GCM in JOB_HASH_ALG list.
I think instead what's missing is NULL_HASH, which block size should be 0.

Thanks,
Pablo
  

Patch

diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
index 4d439360f..dda78d989 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h
@@ -41,6 +41,14 @@  static const unsigned auth_blocksize[] = {
 		[SHA_512]	= 128,
 		[AES_XCBC]	= 16,
 		[AES_CCM]	= 16,
+		[AES_CMAC]	= 16,
+		[AES_GMAC]	= 16,
+		[AES_GCM]	= 16,
+		[PLAIN_SHA1]	= 64,
+		[PLAIN_SHA_224]	= 64,
+		[PLAIN_SHA_256]	= 64,
+		[PLAIN_SHA_384]	= 128,
+		[PLAIN_SHA_512]	= 128
 };
 
 /**
@@ -65,7 +73,13 @@  static const unsigned auth_truncated_digest_byte_lengths[] = {
 		[AES_XCBC]	= 12,
 		[AES_CMAC]	= 12,
 		[AES_CCM]	= 8,
-		[NULL_HASH]	= 0
+		[NULL_HASH]	= 0,
+		[AES_GMAC]	= 16,
+		[PLAIN_SHA1]	= 20,
+		[PLAIN_SHA_224]	= 28,
+		[PLAIN_SHA_256]	= 32,
+		[PLAIN_SHA_384]	= 48,
+		[PLAIN_SHA_512]	= 64
 };
 
 /**
@@ -90,6 +104,7 @@  static const unsigned auth_digest_byte_lengths[] = {
 		[SHA_512]	= 64,
 		[AES_XCBC]	= 16,
 		[AES_CMAC]	= 16,
+		[AES_CCM]	= 16,
 		[AES_GMAC]	= 12,
 		[NULL_HASH]	= 0,
 		[PLAIN_SHA1]	= 20,