DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/test: fix array subscript is above array bounds for gcc 4.5
@ 2016-04-07 13:07 Tomasz Kulasek
  2016-04-07 13:15 ` De Lara Guarch, Pablo
  2016-04-07 14:02 ` [dpdk-dev] [PATCH v2] " Tomasz Kulasek
  0 siblings, 2 replies; 6+ messages in thread
From: Tomasz Kulasek @ 2016-04-07 13:07 UTC (permalink / raw)
  To: dev

cc1: warnings being treated as errors
DPDK/app/test/test_cryptodev.c: In function 'test_snow3g_encrypted_authenti
cation.clone.3':
DPDK/x86_64-ivshmem-linuxapp-gcc/include/rte_memcpy.h:796:14: error: array
subscript is above array bounds
compilation terminated due to -Wfatal-errors.


ROOT OF PROBLEM:
----------------

In lines like:

    rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);

when "iv" is 64 bytes long array, and "iv_len" is "unsigned int",
compiler tries to evaluate also a code for array size larger than 255 bytes
long and reports error "array subscript is above array bounds" in line:

rte_memcpy.h:796

    rte_mov128((uint8_t *)dst + 128, (const uint8_t *)src + 128);

caused by evaluation to:

    rte_mov128((uint8_t *)sym_op->cipher.iv.data + 128, (const uint8_t *)iv
			+ 128);

where "iv" is 64 bytes long buffer and "iv + 128" point out of it, gcc 4.5.


SOLUTION:
---------

Using uint8_t as a size of copied block prevents to evaluate in rte_memcpy
code for size bigger than 255, causing the problem.


Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 app/test/test_cryptodev.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 0c26804..8e8da98 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2362,10 +2362,10 @@ create_snow3g_hash_operation(const uint8_t *auth_tag,
 static int
 create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 		const unsigned auth_tag_len,
-		const uint8_t *aad, const unsigned aad_len,
+		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		enum rte_crypto_auth_operation op,
-		const uint8_t *iv, const unsigned iv_len,
+		const uint8_t *iv, const uint8_t iv_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
 		const unsigned auth_len, const unsigned auth_offset)
 {
@@ -2460,8 +2460,8 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 
 static int
 create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
-		const uint8_t *iv, const unsigned iv_len,
-		const uint8_t *aad, const unsigned aad_len,
+		const uint8_t *iv, const uint8_t iv_len,
+		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
 		const unsigned auth_len, const unsigned auth_offset)
-- 
1.7.9.5

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

* Re: [dpdk-dev] [PATCH] app/test: fix array subscript is above array bounds for gcc 4.5
  2016-04-07 13:07 [dpdk-dev] [PATCH] app/test: fix array subscript is above array bounds for gcc 4.5 Tomasz Kulasek
@ 2016-04-07 13:15 ` De Lara Guarch, Pablo
  2016-04-07 13:57   ` Kulasek, TomaszX
  2016-04-07 14:02 ` [dpdk-dev] [PATCH v2] " Tomasz Kulasek
  1 sibling, 1 reply; 6+ messages in thread
From: De Lara Guarch, Pablo @ 2016-04-07 13:15 UTC (permalink / raw)
  To: Kulasek, TomaszX, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tomasz Kulasek
> Sent: Thursday, April 07, 2016 2:07 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] app/test: fix array subscript is above array
> bounds for gcc 4.5
> 
> cc1: warnings being treated as errors
> DPDK/app/test/test_cryptodev.c: In function
> 'test_snow3g_encrypted_authenti
> cation.clone.3':
> DPDK/x86_64-ivshmem-linuxapp-gcc/include/rte_memcpy.h:796:14: error:
> array
> subscript is above array bounds
> compilation terminated due to -Wfatal-errors.
> 
> 
> ROOT OF PROBLEM:
> ----------------
> 
> In lines like:
> 
>     rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
> 
> when "iv" is 64 bytes long array, and "iv_len" is "unsigned int",
> compiler tries to evaluate also a code for array size larger than 255 bytes
> long and reports error "array subscript is above array bounds" in line:
> 
> rte_memcpy.h:796
> 
>     rte_mov128((uint8_t *)dst + 128, (const uint8_t *)src + 128);
> 
> caused by evaluation to:
> 
>     rte_mov128((uint8_t *)sym_op->cipher.iv.data + 128, (const uint8_t *)iv
> 			+ 128);
> 
> where "iv" is 64 bytes long buffer and "iv + 128" point out of it, gcc 4.5.
> 
> 
> SOLUTION:
> ---------
> 
> Using uint8_t as a size of copied block prevents to evaluate in rte_memcpy
> code for size bigger than 255, causing the problem.
> 
> 

Don't forget to include the "Fixes" line.
Thanks,
Pablo

> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
> ---
>  app/test/test_cryptodev.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

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

* Re: [dpdk-dev] [PATCH] app/test: fix array subscript is above array bounds for gcc 4.5
  2016-04-07 13:15 ` De Lara Guarch, Pablo
@ 2016-04-07 13:57   ` Kulasek, TomaszX
  0 siblings, 0 replies; 6+ messages in thread
From: Kulasek, TomaszX @ 2016-04-07 13:57 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev



> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Thursday, April 7, 2016 15:15
> To: Kulasek, TomaszX <tomaszx.kulasek@intel.com>; dev@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH] app/test: fix array subscript is above
> array bounds for gcc 4.5
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tomasz Kulasek
> > Sent: Thursday, April 07, 2016 2:07 PM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH] app/test: fix array subscript is above
> > array bounds for gcc 4.5
> >
> > cc1: warnings being treated as errors
> > DPDK/app/test/test_cryptodev.c: In function
> > 'test_snow3g_encrypted_authenti
> > cation.clone.3':
> > DPDK/x86_64-ivshmem-linuxapp-gcc/include/rte_memcpy.h:796:14: error:
> > array
> > subscript is above array bounds
> > compilation terminated due to -Wfatal-errors.
> >
> >
> > ROOT OF PROBLEM:
> > ----------------
> >
> > In lines like:
> >
> >     rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
> >
> > when "iv" is 64 bytes long array, and "iv_len" is "unsigned int",
> > compiler tries to evaluate also a code for array size larger than 255
> > bytes long and reports error "array subscript is above array bounds" in
> line:
> >
> > rte_memcpy.h:796
> >
> >     rte_mov128((uint8_t *)dst + 128, (const uint8_t *)src + 128);
> >
> > caused by evaluation to:
> >
> >     rte_mov128((uint8_t *)sym_op->cipher.iv.data + 128, (const uint8_t
> *)iv
> > 			+ 128);
> >
> > where "iv" is 64 bytes long buffer and "iv + 128" point out of it, gcc
> 4.5.
> >
> >
> > SOLUTION:
> > ---------
> >
> > Using uint8_t as a size of copied block prevents to evaluate in
> > rte_memcpy code for size bigger than 255, causing the problem.
> >
> >
> 
> Don't forget to include the "Fixes" line.
> Thanks,
> Pablo
> 
> > Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
> > ---
> >  app/test/test_cryptodev.c |    8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)

Ok. I'm sending v2

Tomasz.

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

* [dpdk-dev] [PATCH v2] app/test: fix array subscript is above array bounds for gcc 4.5
  2016-04-07 13:07 [dpdk-dev] [PATCH] app/test: fix array subscript is above array bounds for gcc 4.5 Tomasz Kulasek
  2016-04-07 13:15 ` De Lara Guarch, Pablo
@ 2016-04-07 14:02 ` Tomasz Kulasek
  2016-04-07 14:06   ` De Lara Guarch, Pablo
  1 sibling, 1 reply; 6+ messages in thread
From: Tomasz Kulasek @ 2016-04-07 14:02 UTC (permalink / raw)
  To: dev

cc1: warnings being treated as errors
DPDK/app/test/test_cryptodev.c: In function 'test_snow3g_encrypted_authenti
cation.clone.3':
DPDK/x86_64-ivshmem-linuxapp-gcc/include/rte_memcpy.h:796:14: error: array
subscript is above array bounds
compilation terminated due to -Wfatal-errors.


ROOT OF PROBLEM:
----------------

In lines like:

    rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);

when "iv" is 64 bytes long array, and "iv_len" is "unsigned int",
compiler tries to evaluate also a code for array size larger than 255 bytes
long and reports error "array subscript is above array bounds" in line:

rte_memcpy.h:796

    rte_mov128((uint8_t *)dst + 128, (const uint8_t *)src + 128);

caused by evaluation to:

    rte_mov128((uint8_t *)sym_op->cipher.iv.data + 128, (const uint8_t *)iv
			+ 128);

where "iv" is 64 bytes long buffer and "iv + 128" point out of it, gcc 4.5.


SOLUTION:
---------

Using uint8_t as a size of copied block prevents to evaluate in rte_memcpy
code for length bigger than 255, causing the problem.

v2 changes:
 - added fixline

Fixes: 8bdf665fe6c0 ("app/test: add SNOW 3G")

Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 app/test/test_cryptodev.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 0c26804..8e8da98 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2362,10 +2362,10 @@ create_snow3g_hash_operation(const uint8_t *auth_tag,
 static int
 create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 		const unsigned auth_tag_len,
-		const uint8_t *aad, const unsigned aad_len,
+		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		enum rte_crypto_auth_operation op,
-		const uint8_t *iv, const unsigned iv_len,
+		const uint8_t *iv, const uint8_t iv_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
 		const unsigned auth_len, const unsigned auth_offset)
 {
@@ -2460,8 +2460,8 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 
 static int
 create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
-		const uint8_t *iv, const unsigned iv_len,
-		const uint8_t *aad, const unsigned aad_len,
+		const uint8_t *iv, const uint8_t iv_len,
+		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
 		const unsigned auth_len, const unsigned auth_offset)
-- 
1.7.9.5

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

* Re: [dpdk-dev] [PATCH v2] app/test: fix array subscript is above array bounds for gcc 4.5
  2016-04-07 14:02 ` [dpdk-dev] [PATCH v2] " Tomasz Kulasek
@ 2016-04-07 14:06   ` De Lara Guarch, Pablo
  2016-04-07 17:41     ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: De Lara Guarch, Pablo @ 2016-04-07 14:06 UTC (permalink / raw)
  To: Kulasek, TomaszX, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tomasz Kulasek
> Sent: Thursday, April 07, 2016 3:02 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] app/test: fix array subscript is above array
> bounds for gcc 4.5
> 
> cc1: warnings being treated as errors
> DPDK/app/test/test_cryptodev.c: In function
> 'test_snow3g_encrypted_authenti
> cation.clone.3':
> DPDK/x86_64-ivshmem-linuxapp-gcc/include/rte_memcpy.h:796:14: error:
> array
> subscript is above array bounds
> compilation terminated due to -Wfatal-errors.
> 
> 
> ROOT OF PROBLEM:
> ----------------
> 
> In lines like:
> 
>     rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
> 
> when "iv" is 64 bytes long array, and "iv_len" is "unsigned int",
> compiler tries to evaluate also a code for array size larger than 255 bytes
> long and reports error "array subscript is above array bounds" in line:
> 
> rte_memcpy.h:796
> 
>     rte_mov128((uint8_t *)dst + 128, (const uint8_t *)src + 128);
> 
> caused by evaluation to:
> 
>     rte_mov128((uint8_t *)sym_op->cipher.iv.data + 128, (const uint8_t *)iv
> 			+ 128);
> 
> where "iv" is 64 bytes long buffer and "iv + 128" point out of it, gcc 4.5.
> 
> 
> SOLUTION:
> ---------
> 
> Using uint8_t as a size of copied block prevents to evaluate in rte_memcpy
> code for length bigger than 255, causing the problem.
> 
> v2 changes:
>  - added fixline
> 
> Fixes: 8bdf665fe6c0 ("app/test: add SNOW 3G")
> 
> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>

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

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

* Re: [dpdk-dev] [PATCH v2] app/test: fix array subscript is above array bounds for gcc 4.5
  2016-04-07 14:06   ` De Lara Guarch, Pablo
@ 2016-04-07 17:41     ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2016-04-07 17:41 UTC (permalink / raw)
  To: Kulasek, TomaszX; +Cc: dev, De Lara Guarch, Pablo

> > Using uint8_t as a size of copied block prevents to evaluate in rte_memcpy
> > code for length bigger than 255, causing the problem.
> > 
> > v2 changes:
> >  - added fixline
> > 
> > Fixes: 8bdf665fe6c0 ("app/test: add SNOW 3G")
> > 
> > Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
> 
> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied, thanks

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

end of thread, other threads:[~2016-04-07 17:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07 13:07 [dpdk-dev] [PATCH] app/test: fix array subscript is above array bounds for gcc 4.5 Tomasz Kulasek
2016-04-07 13:15 ` De Lara Guarch, Pablo
2016-04-07 13:57   ` Kulasek, TomaszX
2016-04-07 14:02 ` [dpdk-dev] [PATCH v2] " Tomasz Kulasek
2016-04-07 14:06   ` De Lara Guarch, Pablo
2016-04-07 17:41     ` Thomas Monjalon

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