* [dpdk-dev] [PATCH] crypto: use snprintf return value correctly
@ 2017-10-11 9:25 Tomasz Duszynski
2017-10-11 9:58 ` Bruce Richardson
2017-10-11 11:05 ` [dpdk-dev] [PATCH v2] " Tomasz Duszynski
0 siblings, 2 replies; 6+ messages in thread
From: Tomasz Duszynski @ 2017-10-11 9:25 UTC (permalink / raw)
To: dev; +Cc: Tomasz Duszynski
snprintf return value is the length of was encoded into destination
array excluding '\0'. Thus return value equal to the length of the
destination array or more means truncation.
This commit fixes improper use of the return value.
Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
---
drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c | 2 +-
drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c | 4 ++--
drivers/crypto/armv8/rte_armv8_pmd_ops.c | 2 +-
drivers/crypto/kasumi/rte_kasumi_pmd_ops.c | 2 +-
drivers/crypto/null/null_crypto_pmd_ops.c | 2 +-
drivers/crypto/openssl/rte_openssl_pmd_ops.c | 2 +-
drivers/crypto/snow3g/rte_snow3g_pmd_ops.c | 2 +-
drivers/crypto/zuc/rte_zuc_pmd_ops.c | 2 +-
8 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
index 48400ac..0f315f0 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
@@ -195,7 +195,7 @@ aesni_gcm_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"aesni_gcm_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
index 2e52ac2..3b3ef0c 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
@@ -397,7 +397,7 @@ aesni_mb_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"aesni_mb_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
@@ -415,7 +415,7 @@ aesni_mb_pmd_qp_create_processed_ops_ring(struct aesni_mb_qp *qp,
"%s_%s",
qp->name, str);
- if (n > sizeof(ring_name))
+ if (n >= sizeof(ring_name))
return NULL;
r = rte_ring_lookup(ring_name);
diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 00297be..63776b2 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -209,7 +209,7 @@ armv8_crypto_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
n = snprintf(qp->name, sizeof(qp->name), "armv8_crypto_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
index 8033114..4da12f3 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
@@ -183,7 +183,7 @@ kasumi_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"kasumi_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index 7615320..c427050 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -175,7 +175,7 @@ null_crypto_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"null_crypto_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index e1c225d..c572239 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -599,7 +599,7 @@ openssl_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"openssl_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
index ae9569c..157a2de 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
@@ -184,7 +184,7 @@ snow3g_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"snow3g_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
index 52c6aed..243c099 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
@@ -184,7 +184,7 @@ zuc_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"zuc_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] crypto: use snprintf return value correctly
2017-10-11 9:25 [dpdk-dev] [PATCH] crypto: use snprintf return value correctly Tomasz Duszynski
@ 2017-10-11 9:58 ` Bruce Richardson
2017-10-11 10:09 ` De Lara Guarch, Pablo
2017-10-11 11:05 ` [dpdk-dev] [PATCH v2] " Tomasz Duszynski
1 sibling, 1 reply; 6+ messages in thread
From: Bruce Richardson @ 2017-10-11 9:58 UTC (permalink / raw)
To: Tomasz Duszynski; +Cc: dev
On Wed, Oct 11, 2017 at 11:25:40AM +0200, Tomasz Duszynski wrote:
> snprintf return value is the length of was encoded into destination
> array excluding '\0'. Thus return value equal to the length of the
> destination array or more means truncation.
>
> This commit fixes improper use of the return value.
>
> Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
> ---
Good catch.
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] crypto: use snprintf return value correctly
2017-10-11 9:58 ` Bruce Richardson
@ 2017-10-11 10:09 ` De Lara Guarch, Pablo
2017-10-11 10:42 ` Tomasz Duszynski
0 siblings, 1 reply; 6+ messages in thread
From: De Lara Guarch, Pablo @ 2017-10-11 10:09 UTC (permalink / raw)
To: Richardson, Bruce, Tomasz Duszynski; +Cc: dev
Hi,
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
> Sent: Wednesday, October 11, 2017 10:58 AM
> To: Tomasz Duszynski <tdu@semihalf.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] crypto: use snprintf return value correctly
>
> On Wed, Oct 11, 2017 at 11:25:40AM +0200, Tomasz Duszynski wrote:
> > snprintf return value is the length of was encoded into destination
> > array excluding '\0'. Thus return value equal to the length of the
> > destination array or more means truncation.
> >
> > This commit fixes improper use of the return value.
> >
> > Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
> > ---
> Good catch.
>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Since this is a fix, you should add Fixes lines (one per PMD), and CC stable.
Thanks!
Pablo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] crypto: use snprintf return value correctly
2017-10-11 10:09 ` De Lara Guarch, Pablo
@ 2017-10-11 10:42 ` Tomasz Duszynski
0 siblings, 0 replies; 6+ messages in thread
From: Tomasz Duszynski @ 2017-10-11 10:42 UTC (permalink / raw)
To: De Lara Guarch, Pablo; +Cc: Richardson, Bruce, Tomasz Duszynski, dev
On Wed, Oct 11, 2017 at 10:09:02AM +0000, De Lara Guarch, Pablo wrote:
> Hi,
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
> > Sent: Wednesday, October 11, 2017 10:58 AM
> > To: Tomasz Duszynski <tdu@semihalf.com>
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] crypto: use snprintf return value correctly
> >
> > On Wed, Oct 11, 2017 at 11:25:40AM +0200, Tomasz Duszynski wrote:
> > > snprintf return value is the length of was encoded into destination
> > > array excluding '\0'. Thus return value equal to the length of the
> > > destination array or more means truncation.
> > >
> > > This commit fixes improper use of the return value.
> > >
> > > Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
> > > ---
> > Good catch.
> >
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>
> Since this is a fix, you should add Fixes lines (one per PMD), and CC stable.
>
> Thanks!
> Pablo
>
ACK
--
- Tomasz Duszyński
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] crypto: use snprintf return value correctly
2017-10-11 9:25 [dpdk-dev] [PATCH] crypto: use snprintf return value correctly Tomasz Duszynski
2017-10-11 9:58 ` Bruce Richardson
@ 2017-10-11 11:05 ` Tomasz Duszynski
2017-10-12 8:03 ` [dpdk-dev] [dpdk-stable] " De Lara Guarch, Pablo
1 sibling, 1 reply; 6+ messages in thread
From: Tomasz Duszynski @ 2017-10-11 11:05 UTC (permalink / raw)
To: dev; +Cc: Tomasz Duszynski, stable
snprintf return value is the length of was encoded into destination
array excluding '\0'. Thus return value equal to the length of the
destination array or more means truncation.
This commit fixes improper use of the return value.
Fixes: eec136f3c54f ("aesni_gcm: add driver for AES-GCM crypto operations")
Fixes: 924e84f87306 ("aesni_mb: add driver for multi buffer based crypto")
Fixes: 0f548b50a160 ("crypto/aesni_mb: process crypto op on dequeue")
Fixes: 169ca3db550c ("crypto/armv8: add PMD optimized for ARMv8 processors")
Fixes: 2773c86d061a ("crypto/kasumi: add driver for KASUMI library")
Fixes: 94b0ad8e0aa5 ("null_crypto: add driver for null crypto operations")
Fixes: d61f70b4c918 ("crypto/libcrypto: add driver for OpenSSL library")
Fixes: 3aafc423cf4d ("snow3g: add driver for SNOW 3G library")
Fixes: cf7685d68f00 ("crypto/zuc: add driver for ZUC library")
Cc: stable@dpdk.org
Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c | 2 +-
drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c | 4 ++--
drivers/crypto/armv8/rte_armv8_pmd_ops.c | 2 +-
drivers/crypto/kasumi/rte_kasumi_pmd_ops.c | 2 +-
drivers/crypto/null/null_crypto_pmd_ops.c | 2 +-
drivers/crypto/openssl/rte_openssl_pmd_ops.c | 2 +-
drivers/crypto/snow3g/rte_snow3g_pmd_ops.c | 2 +-
drivers/crypto/zuc/rte_zuc_pmd_ops.c | 2 +-
8 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
index 48400ac..0f315f0 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
@@ -195,7 +195,7 @@ aesni_gcm_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"aesni_gcm_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
index 2e52ac2..3b3ef0c 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
@@ -397,7 +397,7 @@ aesni_mb_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"aesni_mb_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
@@ -415,7 +415,7 @@ aesni_mb_pmd_qp_create_processed_ops_ring(struct aesni_mb_qp *qp,
"%s_%s",
qp->name, str);
- if (n > sizeof(ring_name))
+ if (n >= sizeof(ring_name))
return NULL;
r = rte_ring_lookup(ring_name);
diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 00297be..63776b2 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -209,7 +209,7 @@ armv8_crypto_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
n = snprintf(qp->name, sizeof(qp->name), "armv8_crypto_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
index 8033114..4da12f3 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
@@ -183,7 +183,7 @@ kasumi_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"kasumi_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index 7615320..c427050 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -175,7 +175,7 @@ null_crypto_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"null_crypto_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index e1c225d..c572239 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -599,7 +599,7 @@ openssl_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"openssl_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
index ae9569c..157a2de 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
@@ -184,7 +184,7 @@ snow3g_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"snow3g_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
index 52c6aed..243c099 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
@@ -184,7 +184,7 @@ zuc_pmd_qp_set_unique_name(struct rte_cryptodev *dev,
"zuc_pmd_%u_qp_%u",
dev->data->dev_id, qp->id);
- if (n > sizeof(qp->name))
+ if (n >= sizeof(qp->name))
return -1;
return 0;
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH v2] crypto: use snprintf return value correctly
2017-10-11 11:05 ` [dpdk-dev] [PATCH v2] " Tomasz Duszynski
@ 2017-10-12 8:03 ` De Lara Guarch, Pablo
0 siblings, 0 replies; 6+ messages in thread
From: De Lara Guarch, Pablo @ 2017-10-12 8:03 UTC (permalink / raw)
To: Tomasz Duszynski, dev; +Cc: stable
> -----Original Message-----
> From: stable [mailto:stable-bounces@dpdk.org] On Behalf Of Tomasz
> Duszynski
> Sent: Wednesday, October 11, 2017 12:05 PM
> To: dev@dpdk.org
> Cc: Tomasz Duszynski <tdu@semihalf.com>; stable@dpdk.org
> Subject: [dpdk-stable] [PATCH v2] crypto: use snprintf return value correctly
>
> snprintf return value is the length of was encoded into destination array
> excluding '\0'. Thus return value equal to the length of the destination array
> or more means truncation.
>
> This commit fixes improper use of the return value.
>
> Fixes: eec136f3c54f ("aesni_gcm: add driver for AES-GCM crypto
> operations")
> Fixes: 924e84f87306 ("aesni_mb: add driver for multi buffer based crypto")
> Fixes: 0f548b50a160 ("crypto/aesni_mb: process crypto op on dequeue")
> Fixes: 169ca3db550c ("crypto/armv8: add PMD optimized for ARMv8
> processors")
> Fixes: 2773c86d061a ("crypto/kasumi: add driver for KASUMI library")
> Fixes: 94b0ad8e0aa5 ("null_crypto: add driver for null crypto operations")
> Fixes: d61f70b4c918 ("crypto/libcrypto: add driver for OpenSSL library")
> Fixes: 3aafc423cf4d ("snow3g: add driver for SNOW 3G library")
> Fixes: cf7685d68f00 ("crypto/zuc: add driver for ZUC library")
> Cc: stable@dpdk.org
>
> Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Applied to dpdk-next-crypto.
Thanks,
Pablo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-12 8:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-11 9:25 [dpdk-dev] [PATCH] crypto: use snprintf return value correctly Tomasz Duszynski
2017-10-11 9:58 ` Bruce Richardson
2017-10-11 10:09 ` De Lara Guarch, Pablo
2017-10-11 10:42 ` Tomasz Duszynski
2017-10-11 11:05 ` [dpdk-dev] [PATCH v2] " Tomasz Duszynski
2017-10-12 8:03 ` [dpdk-dev] [dpdk-stable] " 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).