[v2] test/ipsec: fix build with GCC 12

Message ID 20220616093320.884583-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series [v2] test/ipsec: fix build with GCC 12 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

David Marchand June 16, 2022, 9:33 a.m. UTC
  GCC 12 raises the following warning:

In function ‘_mm256_loadu_si256’,
    inlined from ‘rte_mov32’ at
        ../lib/eal/x86/include/rte_memcpy.h:319:9,
    inlined from ‘rte_mov128’ at
        ../lib/eal/x86/include/rte_memcpy.h:344:2,
    inlined from ‘rte_memcpy_generic’ at
        ../lib/eal/x86/include/rte_memcpy.h:438:4,
    inlined from ‘rte_memcpy’ at
        ../lib/eal/x86/include/rte_memcpy.h:882:10,
    inlined from ‘setup_test_string.constprop’ at
        ../app/test/test_ipsec.c:572:4:
/usr/lib/gcc/x86_64-redhat-linux/12/include/avxintrin.h:929:10: error:
    array subscript ‘__m256i_u[3]’ is partly outside array bounds of
    ‘const char[108]’ [-Werror=array-bounds]
  929 |   return *__P;
      |          ^~~~
../app/test/test_ipsec.c: In function ‘setup_test_string.constprop’:
../app/test/test_ipsec.c:539:12: note: at offset 96 into object
    ‘null_plain_data’ of size 108
  539 | const char null_plain_data[] =
      |            ^~~~~~~~~~~~~~~

Add a hint so that the compiler understands the copied data is within
the passed string boundaries.

Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since v1:
- let the code as is, simply added a RTE_VERIFY hint,

---
 app/test/test_ipsec.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
  

Comments

David Marchand June 17, 2022, 12:06 p.m. UTC | #1
On Thu, Jun 16, 2022 at 11:33 AM David Marchand
<david.marchand@redhat.com> wrote:
>
> GCC 12 raises the following warning:
>
> In function ‘_mm256_loadu_si256’,
>     inlined from ‘rte_mov32’ at
>         ../lib/eal/x86/include/rte_memcpy.h:319:9,
>     inlined from ‘rte_mov128’ at
>         ../lib/eal/x86/include/rte_memcpy.h:344:2,
>     inlined from ‘rte_memcpy_generic’ at
>         ../lib/eal/x86/include/rte_memcpy.h:438:4,
>     inlined from ‘rte_memcpy’ at
>         ../lib/eal/x86/include/rte_memcpy.h:882:10,
>     inlined from ‘setup_test_string.constprop’ at
>         ../app/test/test_ipsec.c:572:4:
> /usr/lib/gcc/x86_64-redhat-linux/12/include/avxintrin.h:929:10: error:
>     array subscript ‘__m256i_u[3]’ is partly outside array bounds of
>     ‘const char[108]’ [-Werror=array-bounds]
>   929 |   return *__P;
>       |          ^~~~
> ../app/test/test_ipsec.c: In function ‘setup_test_string.constprop’:
> ../app/test/test_ipsec.c:539:12: note: at offset 96 into object
>     ‘null_plain_data’ of size 108
>   539 | const char null_plain_data[] =
>       |            ^~~~~~~~~~~~~~~
>
> Add a hint so that the compiler understands the copied data is within
> the passed string boundaries.
>

Ferruh had opened a bz.

Bugzilla ID: 848
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
  
Akhil Goyal June 20, 2022, 9:07 a.m. UTC | #2
> On Thu, Jun 16, 2022 at 11:33 AM David Marchand
> <david.marchand@redhat.com> wrote:
> >
> > GCC 12 raises the following warning:
> >
> > In function ‘_mm256_loadu_si256’,
> >     inlined from ‘rte_mov32’ at
> >         ../lib/eal/x86/include/rte_memcpy.h:319:9,
> >     inlined from ‘rte_mov128’ at
> >         ../lib/eal/x86/include/rte_memcpy.h:344:2,
> >     inlined from ‘rte_memcpy_generic’ at
> >         ../lib/eal/x86/include/rte_memcpy.h:438:4,
> >     inlined from ‘rte_memcpy’ at
> >         ../lib/eal/x86/include/rte_memcpy.h:882:10,
> >     inlined from ‘setup_test_string.constprop’ at
> >         ../app/test/test_ipsec.c:572:4:
> > /usr/lib/gcc/x86_64-redhat-linux/12/include/avxintrin.h:929:10: error:
> >     array subscript ‘__m256i_u[3]’ is partly outside array bounds of
> >     ‘const char[108]’ [-Werror=array-bounds]
> >   929 |   return *__P;
> >       |          ^~~~
> > ../app/test/test_ipsec.c: In function ‘setup_test_string.constprop’:
> > ../app/test/test_ipsec.c:539:12: note: at offset 96 into object
> >     ‘null_plain_data’ of size 108
> >   539 | const char null_plain_data[] =
> >       |            ^~~~~~~~~~~~~~~
> >
> > Add a hint so that the compiler understands the copied data is within
> > the passed string boundaries.
> >
> 
> Ferruh had opened a bz.
> 
> Bugzilla ID: 848
Added Fixes tag also.

Applied to dpdk-next-crypto

Thanks.

> > Cc: stable@dpdk.org
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
  
Vladimir Medvedkin June 20, 2022, 3:06 p.m. UTC | #3
On 17/06/2022 13:06, David Marchand wrote:
> On Thu, Jun 16, 2022 at 11:33 AM David Marchand
> <david.marchand@redhat.com> wrote:
>> GCC 12 raises the following warning:
>>
>> In function ‘_mm256_loadu_si256’,
>>      inlined from ‘rte_mov32’ at
>>          ../lib/eal/x86/include/rte_memcpy.h:319:9,
>>      inlined from ‘rte_mov128’ at
>>          ../lib/eal/x86/include/rte_memcpy.h:344:2,
>>      inlined from ‘rte_memcpy_generic’ at
>>          ../lib/eal/x86/include/rte_memcpy.h:438:4,
>>      inlined from ‘rte_memcpy’ at
>>          ../lib/eal/x86/include/rte_memcpy.h:882:10,
>>      inlined from ‘setup_test_string.constprop’ at
>>          ../app/test/test_ipsec.c:572:4:
>> /usr/lib/gcc/x86_64-redhat-linux/12/include/avxintrin.h:929:10: error:
>>      array subscript ‘__m256i_u[3]’ is partly outside array bounds of
>>      ‘const char[108]’ [-Werror=array-bounds]
>>    929 |   return *__P;
>>        |          ^~~~
>> ../app/test/test_ipsec.c: In function ‘setup_test_string.constprop’:
>> ../app/test/test_ipsec.c:539:12: note: at offset 96 into object
>>      ‘null_plain_data’ of size 108
>>    539 | const char null_plain_data[] =
>>        |            ^~~~~~~~~~~~~~~
>>
>> Add a hint so that the compiler understands the copied data is within
>> the passed string boundaries.
>>
> Ferruh had opened a bz.
>
> Bugzilla ID: 848
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: David Marchand <david.marchand@redhat.com>


Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

>
  

Patch

diff --git a/app/test/test_ipsec.c b/app/test/test_ipsec.c
index 8da025bf66..7047e17960 100644
--- a/app/test/test_ipsec.c
+++ b/app/test/test_ipsec.c
@@ -554,12 +554,14 @@  struct rte_ipv4_hdr ipv4_outer  = {
 };
 
 static struct rte_mbuf *
-setup_test_string(struct rte_mempool *mpool,
-		const char *string, size_t len, uint8_t blocksize)
+setup_test_string(struct rte_mempool *mpool, const char *string,
+	size_t string_len, size_t len, uint8_t blocksize)
 {
 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
 
+	RTE_VERIFY(len <= string_len);
+
 	if (m) {
 		memset(m->buf_addr, 0, m->buf_len);
 		char *dst = rte_pktmbuf_append(m, t_len);
@@ -1365,7 +1367,8 @@  test_ipsec_crypto_outb_burst_null_null(int i)
 	/* Generate input mbuf data */
 	for (j = 0; j < num_pkts && rc == 0; j++) {
 		ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool,
-			null_plain_data, test_cfg[i].pkt_sz, 0);
+			null_plain_data, sizeof(null_plain_data),
+			test_cfg[i].pkt_sz, 0);
 		if (ut_params->ibuf[j] == NULL)
 			rc = TEST_FAILED;
 		else {
@@ -1483,7 +1486,8 @@  test_ipsec_inline_crypto_inb_burst_null_null(int i)
 			/* Generate test mbuf data */
 			ut_params->obuf[j] = setup_test_string(
 				ts_params->mbuf_pool,
-				null_plain_data, test_cfg[i].pkt_sz, 0);
+				null_plain_data, sizeof(null_plain_data),
+				test_cfg[i].pkt_sz, 0);
 			if (ut_params->obuf[j] == NULL)
 				rc = TEST_FAILED;
 		}
@@ -1551,16 +1555,17 @@  test_ipsec_inline_proto_inb_burst_null_null(int i)
 
 	/* Generate inbound mbuf data */
 	for (j = 0; j < num_pkts && rc == 0; j++) {
-		ut_params->ibuf[j] = setup_test_string(
-			ts_params->mbuf_pool,
-			null_plain_data, test_cfg[i].pkt_sz, 0);
+		ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool,
+			null_plain_data, sizeof(null_plain_data),
+			test_cfg[i].pkt_sz, 0);
 		if (ut_params->ibuf[j] == NULL)
 			rc = TEST_FAILED;
 		else {
 			/* Generate test mbuf data */
 			ut_params->obuf[j] = setup_test_string(
 				ts_params->mbuf_pool,
-				null_plain_data, test_cfg[i].pkt_sz, 0);
+				null_plain_data, sizeof(null_plain_data),
+				test_cfg[i].pkt_sz, 0);
 			if (ut_params->obuf[j] == NULL)
 				rc = TEST_FAILED;
 		}
@@ -1660,7 +1665,8 @@  test_ipsec_inline_crypto_outb_burst_null_null(int i)
 	/* Generate test mbuf data */
 	for (j = 0; j < num_pkts && rc == 0; j++) {
 		ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool,
-			null_plain_data, test_cfg[i].pkt_sz, 0);
+			null_plain_data, sizeof(null_plain_data),
+			test_cfg[i].pkt_sz, 0);
 		if (ut_params->ibuf[0] == NULL)
 			rc = TEST_FAILED;
 
@@ -1738,15 +1744,17 @@  test_ipsec_inline_proto_outb_burst_null_null(int i)
 	/* Generate test mbuf data */
 	for (j = 0; j < num_pkts && rc == 0; j++) {
 		ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool,
-			null_plain_data, test_cfg[i].pkt_sz, 0);
+			null_plain_data, sizeof(null_plain_data),
+			test_cfg[i].pkt_sz, 0);
 		if (ut_params->ibuf[0] == NULL)
 			rc = TEST_FAILED;
 
 		if (rc == 0) {
 			/* Generate test tunneled mbuf data for comparison */
 			ut_params->obuf[j] = setup_test_string(
-					ts_params->mbuf_pool,
-					null_plain_data, test_cfg[i].pkt_sz, 0);
+				ts_params->mbuf_pool, null_plain_data,
+				sizeof(null_plain_data), test_cfg[i].pkt_sz,
+				0);
 			if (ut_params->obuf[j] == NULL)
 				rc = TEST_FAILED;
 		}
@@ -1815,7 +1823,8 @@  test_ipsec_lksd_proto_inb_burst_null_null(int i)
 	for (j = 0; j < num_pkts && rc == 0; j++) {
 		/* packet with sequence number 0 is invalid */
 		ut_params->ibuf[j] = setup_test_string(ts_params->mbuf_pool,
-			null_encrypted_data, test_cfg[i].pkt_sz, 0);
+			null_encrypted_data, sizeof(null_encrypted_data),
+			test_cfg[i].pkt_sz, 0);
 		if (ut_params->ibuf[j] == NULL)
 			rc = TEST_FAILED;
 	}