DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode
@ 2018-07-11 12:24 Dmitry Eremin-Solenikov
  2018-07-11 18:02 ` [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params Fiona Trahe
  2018-07-11 18:04 ` [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode Trahe, Fiona
  0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Eremin-Solenikov @ 2018-07-11 12:24 UTC (permalink / raw)
  To: dev

QAT driver checks byte alignment for KASUMI/SNOW 3G/ZUC algorithms using
cipher/auth_param, which are not initialized at this moment yet. Use
operation params instead.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
---
 drivers/crypto/qat/qat_sym.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index 17d63eb1ee35..0ede2c23d54f 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -224,18 +224,16 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 			ctx->qat_cipher_alg ==
 				ICP_QAT_HW_CIPHER_ALGO_ZUC_3G_128_EEA3) {
 
-			if (unlikely(
-				(cipher_param->cipher_length % BYTE_LENGTH != 0)
-				 || (cipher_param->cipher_offset
-							% BYTE_LENGTH != 0))) {
+			cipher_len = op->sym->cipher.data.length >> 3;
+			cipher_ofs = op->sym->cipher.data.offset >> 3;
+
+			if (unlikely((cipher_len % BYTE_LENGTH != 0)
+				|| (cipher_ofs % BYTE_LENGTH != 0))) {
 				QAT_DP_LOG(ERR,
 		  "SNOW3G/KASUMI/ZUC in QAT PMD only supports byte aligned values");
 				op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 				return -EINVAL;
 			}
-			cipher_len = op->sym->cipher.data.length >> 3;
-			cipher_ofs = op->sym->cipher.data.offset >> 3;
-
 		} else if (ctx->bpi_ctx) {
 			/* DOCSIS - only send complete blocks to device
 			 * Process any partial block using CFB mode.
@@ -260,15 +258,17 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 			ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_KASUMI_F9 ||
 			ctx->qat_hash_alg ==
 				ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3) {
-			if (unlikely((auth_param->auth_off % BYTE_LENGTH != 0)
-				|| (auth_param->auth_len % BYTE_LENGTH != 0))) {
+
+			auth_ofs = op->sym->auth.data.offset >> 3;
+			auth_len = op->sym->auth.data.length >> 3;
+
+			if (unlikely((auth_off % BYTE_LENGTH != 0)
+				|| (auth_len % BYTE_LENGTH != 0))) {
 				QAT_DP_LOG(ERR,
 		"For SNOW3G/KASUMI/ZUC, QAT PMD only supports byte aligned values");
 				op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 				return -EINVAL;
 			}
-			auth_ofs = op->sym->auth.data.offset >> 3;
-			auth_len = op->sym->auth.data.length >> 3;
 
 			auth_param->u1.aad_adr =
 					rte_crypto_op_ctophys_offset(op,
-- 
2.18.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params
  2018-07-11 12:24 [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode Dmitry Eremin-Solenikov
@ 2018-07-11 18:02 ` Fiona Trahe
  2018-07-12  8:19   ` Dmitry Eremin-Solenikov
  2018-07-13 14:15   ` De Lara Guarch, Pablo
  2018-07-11 18:04 ` [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode Trahe, Fiona
  1 sibling, 2 replies; 7+ messages in thread
From: Fiona Trahe @ 2018-07-11 18:02 UTC (permalink / raw)
  To: dev, dmitry.ereminsolenikov; +Cc: pablo.de.lara.guarch, fiona.trahe

QAT driver checks byte alignment for KASUMI/SNOW 3G/ZUC algorithms using
cipher/auth_param, which are not initialized at this moment yet. Use
operation params instead.

Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
---
Change in v2 :
- fixed implementation to avoid data truncation

This fix should be backported to stable.
In 18.08 the code location has changed.
In earlier releases it was 
in qat_write_hw_desc_entry() in qat/qat_crypto.c



 drivers/crypto/qat/qat_sym.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index aa6eeb0..4ed7d95 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -225,9 +225,8 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 				ICP_QAT_HW_CIPHER_ALGO_ZUC_3G_128_EEA3) {
 
 			if (unlikely(
-				(cipher_param->cipher_length % BYTE_LENGTH != 0)
-				 || (cipher_param->cipher_offset
-							% BYTE_LENGTH != 0))) {
+			    (op->sym->cipher.data.length % BYTE_LENGTH != 0) ||
+			    (op->sym->cipher.data.offset % BYTE_LENGTH != 0))) {
 				QAT_DP_LOG(ERR,
 		  "SNOW3G/KASUMI/ZUC in QAT PMD only supports byte aligned values");
 				op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
@@ -260,8 +259,9 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 			ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_KASUMI_F9 ||
 			ctx->qat_hash_alg ==
 				ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3) {
-			if (unlikely((auth_param->auth_off % BYTE_LENGTH != 0)
-				|| (auth_param->auth_len % BYTE_LENGTH != 0))) {
+			if (unlikely(
+			    (op->sym->auth.data.offset % BYTE_LENGTH != 0) ||
+			    (op->sym->auth.data.length % BYTE_LENGTH != 0))) {
 				QAT_DP_LOG(ERR,
 		"For SNOW3G/KASUMI/ZUC, QAT PMD only supports byte aligned values");
 				op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode
  2018-07-11 12:24 [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode Dmitry Eremin-Solenikov
  2018-07-11 18:02 ` [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params Fiona Trahe
@ 2018-07-11 18:04 ` Trahe, Fiona
  2018-07-13 13:02   ` De Lara Guarch, Pablo
  1 sibling, 1 reply; 7+ messages in thread
From: Trahe, Fiona @ 2018-07-11 18:04 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov, dev; +Cc: Trahe, Fiona

Hi Dmitri,

Thanks for debugging this. 
However the below fix can truncate the data - I'll send an alternative fix shortly.
Fiona

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Dmitry Eremin-Solenikov
> Sent: Wednesday, July 11, 2018 1:25 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode
> 
> QAT driver checks byte alignment for KASUMI/SNOW 3G/ZUC algorithms using
> cipher/auth_param, which are not initialized at this moment yet. Use
> operation params instead.
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
> ---
>  drivers/crypto/qat/qat_sym.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
> index 17d63eb1ee35..0ede2c23d54f 100644
> --- a/drivers/crypto/qat/qat_sym.c
> +++ b/drivers/crypto/qat/qat_sym.c
> @@ -224,18 +224,16 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
>  			ctx->qat_cipher_alg ==
>  				ICP_QAT_HW_CIPHER_ALGO_ZUC_3G_128_EEA3) {
> 
> -			if (unlikely(
> -				(cipher_param->cipher_length % BYTE_LENGTH != 0)
> -				 || (cipher_param->cipher_offset
> -							% BYTE_LENGTH != 0))) {
> +			cipher_len = op->sym->cipher.data.length >> 3;
> +			cipher_ofs = op->sym->cipher.data.offset >> 3;
> +
> +			if (unlikely((cipher_len % BYTE_LENGTH != 0)
> +				|| (cipher_ofs % BYTE_LENGTH != 0))) {
>  				QAT_DP_LOG(ERR,
>  		  "SNOW3G/KASUMI/ZUC in QAT PMD only supports byte aligned values");
>  				op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
>  				return -EINVAL;
>  			}
> -			cipher_len = op->sym->cipher.data.length >> 3;
> -			cipher_ofs = op->sym->cipher.data.offset >> 3;
> -
>  		} else if (ctx->bpi_ctx) {
>  			/* DOCSIS - only send complete blocks to device
>  			 * Process any partial block using CFB mode.
> @@ -260,15 +258,17 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
>  			ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_KASUMI_F9 ||
>  			ctx->qat_hash_alg ==
>  				ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3) {
> -			if (unlikely((auth_param->auth_off % BYTE_LENGTH != 0)
> -				|| (auth_param->auth_len % BYTE_LENGTH != 0))) {
> +
> +			auth_ofs = op->sym->auth.data.offset >> 3;
> +			auth_len = op->sym->auth.data.length >> 3;
> +
> +			if (unlikely((auth_off % BYTE_LENGTH != 0)
> +				|| (auth_len % BYTE_LENGTH != 0))) {
>  				QAT_DP_LOG(ERR,
>  		"For SNOW3G/KASUMI/ZUC, QAT PMD only supports byte aligned values");
>  				op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
>  				return -EINVAL;
>  			}
> -			auth_ofs = op->sym->auth.data.offset >> 3;
> -			auth_len = op->sym->auth.data.length >> 3;
> 
>  			auth_param->u1.aad_adr =
>  					rte_crypto_op_ctophys_offset(op,
> --
> 2.18.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params
  2018-07-11 18:02 ` [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params Fiona Trahe
@ 2018-07-12  8:19   ` Dmitry Eremin-Solenikov
  2018-07-13 14:15   ` De Lara Guarch, Pablo
  1 sibling, 0 replies; 7+ messages in thread
From: Dmitry Eremin-Solenikov @ 2018-07-12  8:19 UTC (permalink / raw)
  To: Fiona Trahe; +Cc: dev, pablo.de.lara.guarch

On 11 July 2018 at 21:02, Fiona Trahe <fiona.trahe@intel.com> wrote:
> QAT driver checks byte alignment for KASUMI/SNOW 3G/ZUC algorithms using
> cipher/auth_param, which are not initialized at this moment yet. Use
> operation params instead.
>
> Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>

Thanks, this should fix the issue.

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode
  2018-07-11 18:04 ` [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode Trahe, Fiona
@ 2018-07-13 13:02   ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 7+ messages in thread
From: De Lara Guarch, Pablo @ 2018-07-13 13:02 UTC (permalink / raw)
  To: Trahe, Fiona, Dmitry Eremin-Solenikov, dev; +Cc: Trahe, Fiona

Hi Fiona,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Trahe, Fiona
> Sent: Wednesday, July 11, 2018 7:04 PM
> To: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>;
> dev@dpdk.org
> Cc: Trahe, Fiona <fiona.trahe@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode
> 
> Hi Dmitri,
> 
> Thanks for debugging this.
> However the below fix can truncate the data - I'll send an alternative fix shortly.
> Fiona
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Dmitry
> > Eremin-Solenikov
> > Sent: Wednesday, July 11, 2018 1:25 PM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit
> > mode
> >
> > QAT driver checks byte alignment for KASUMI/SNOW 3G/ZUC algorithms
> > using cipher/auth_param, which are not initialized at this moment yet.
> > Use operation params instead.
> >
> > Signed-off-by: Dmitry Eremin-Solenikov
> > <dmitry.ereminsolenikov@linaro.org>

I'll add a Reported-by line for Dmitry, for flagging the issue.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params
  2018-07-11 18:02 ` [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params Fiona Trahe
  2018-07-12  8:19   ` Dmitry Eremin-Solenikov
@ 2018-07-13 14:15   ` De Lara Guarch, Pablo
  2018-07-13 14:31     ` De Lara Guarch, Pablo
  1 sibling, 1 reply; 7+ messages in thread
From: De Lara Guarch, Pablo @ 2018-07-13 14:15 UTC (permalink / raw)
  To: Trahe, Fiona, dev, dmitry.ereminsolenikov



> -----Original Message-----
> From: Trahe, Fiona
> Sent: Wednesday, July 11, 2018 7:03 PM
> To: dev@dpdk.org; dmitry.ereminsolenikov@linaro.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; Trahe, Fiona
> <fiona.trahe@intel.com>
> Subject: [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params
> 
> QAT driver checks byte alignment for KASUMI/SNOW 3G/ZUC algorithms using
> cipher/auth_param, which are not initialized at this moment yet. Use operation
> params instead.
> 
> Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
> ---

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params
  2018-07-13 14:15   ` De Lara Guarch, Pablo
@ 2018-07-13 14:31     ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 7+ messages in thread
From: De Lara Guarch, Pablo @ 2018-07-13 14:31 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, Trahe, Fiona, dev, dmitry.ereminsolenikov; +Cc: stable



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of De Lara Guarch, Pablo
> Sent: Friday, July 13, 2018 3:15 PM
> To: Trahe, Fiona <fiona.trahe@intel.com>; dev@dpdk.org;
> dmitry.ereminsolenikov@linaro.org
> Subject: Re: [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit
> params
> 
> 
> 
> > -----Original Message-----
> > From: Trahe, Fiona
> > Sent: Wednesday, July 11, 2018 7:03 PM
> > To: dev@dpdk.org; dmitry.ereminsolenikov@linaro.org
> > Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; Trahe,
> > Fiona <fiona.trahe@intel.com>
> > Subject: [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params
> >
> > QAT driver checks byte alignment for KASUMI/SNOW 3G/ZUC algorithms
> > using cipher/auth_param, which are not initialized at this moment yet.
> > Use operation params instead.
> >
> > Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
> > ---
> 
> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Added Fixes line and Cc stable.

Applied to dpdk-next-crypto.
Thanks,

Pablo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-07-13 14:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-11 12:24 [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode Dmitry Eremin-Solenikov
2018-07-11 18:02 ` [dpdk-dev] [PATCH v2] crypto/qat: fix checks for 3gpp algo bit params Fiona Trahe
2018-07-12  8:19   ` Dmitry Eremin-Solenikov
2018-07-13 14:15   ` De Lara Guarch, Pablo
2018-07-13 14:31     ` De Lara Guarch, Pablo
2018-07-11 18:04 ` [dpdk-dev] [PATCH] qat: fix checks for 3gpp algorithms vs bit mode Trahe, Fiona
2018-07-13 13:02   ` De Lara Guarch, Pablo

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).