Skip to contentSkip to conversation

gcc 10 disable stringop-overflow warning

RFC In review Kevin Traynor 5 participants 18 messages Mar 25, 2020 – May 6, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover gcc 10 disable stringop-overflow warning

This is a blunt way to remove this warning.

Some alternatives are:
- disable the warning for individual components
- components rework to statically allocate memory for parts of structs impacted

Maybe there's some other solutions?

Impacted components:
../drivers/crypto/caam_jr/caam_jr_pvt.h
../drivers/crypto/ccp/ccp_crypto.h
../drivers/crypto/dpaa_sec/dpaa_sec.h
../drivers/crypto/virtio/virtio_cryptodev.h
../drivers/net/enic/base/vnic_dev.c
../drivers/net/iavf/../../common/iavf/virtchnl.h
../drivers/net/ice/base/ice_adminq_cmd.h
../drivers/net/mlx4/mlx4_rxtx.c
../drivers/net/qede/base/ecore_mcp.c
../lib/librte_cryptodev/rte_cryptodev.h
../lib/librte_pipeline/rte_table_action.c

Full details in the Bugzilla:
https://bugs.dpdk.org/show_bug.cgi?id=421

Kevin Traynor (2):
meson: gcc 10 disable stringop-overflow warnings
mk: gcc 10 disable stringop-overflow warnings

 config/meson.build           | 3 ++-
 mk/toolchain/gcc/rte.vars.mk | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.21.1
#1 lore raw

RFC 1/2 meson: gcc 10 disable stringop-overflow warnings

Disable this warning at the top level as it is being raised on several components.

Bugzilla ID: 421

---
 config/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
config/meson.build +2 -1
index abedd76f2..522368a29 100644
@@ -200,5 +200,6 @@ warning_flags = [
 	'-Wno-address-of-packed-member',
 	'-Wno-packed-not-aligned',
-	'-Wno-missing-field-initializers'
+	'-Wno-missing-field-initializers',
+	'-Wno-stringop-overflow'
 ]
 if not dpdk_conf.get('RTE_ARCH_64')
Signature · 1 line
2.21.1
#2 lore raw

RFC 2/2 mk: gcc 10 disable stringop-overflow warnings

In reply to Kevin Traynor

Disable this warning at the top level as it is being raised on several components.

Bugzilla ID: 421

---
 mk/toolchain/gcc/rte.vars.mk | 3 +++
 1 file changed, 3 insertions(+)
mk/toolchain/gcc/rte.vars.mk +3 -0
index f19305e49..fe4b8c705 100644
@@ -101,4 +101,7 @@ endif
 WERROR_FLAGS += -Wno-address-of-packed-member
 
+# disable stringop-overflow warnings
+WERROR_FLAGS += -Wno-stringop-overflow
+
 export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF
 export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS
Signature · 1 line
2.21.1
#3 lore raw
In reply to Kevin Traynor

25/03/2020 15:11, Kevin Traynor:

Quoted 7 lines

This is a blunt way to remove this warning.

Some alternatives are:
- disable the warning for individual components
- components rework to statically allocate memory for parts of structs impacted

Maybe there's some other solutions?

In general, I am against disabling warnings, neither globally nor specifically. Is there a way to hide false positives without disabling the warning?

Quoted 13 lines

Impacted components:
../drivers/crypto/caam_jr/caam_jr_pvt.h
../drivers/crypto/ccp/ccp_crypto.h
../drivers/crypto/dpaa_sec/dpaa_sec.h
../drivers/crypto/virtio/virtio_cryptodev.h
../drivers/net/enic/base/vnic_dev.c
../drivers/net/iavf/../../common/iavf/virtchnl.h
../drivers/net/ice/base/ice_adminq_cmd.h
../drivers/net/mlx4/mlx4_rxtx.c
../drivers/net/qede/base/ecore_mcp.c
../lib/librte_cryptodev/rte_cryptodev.h
../lib/librte_pipeline/rte_table_action.c

Quoted 2 lines

Full details in the Bugzilla:
https://bugs.dpdk.org/show_bug.cgi?id=421

Would be easier to provide explanations here. I think we need at least one false positive example.

Quoted 3 lines

Kevin Traynor (2):
meson: gcc 10 disable stringop-overflow warnings
mk: gcc 10 disable stringop-overflow warnings

You don't need to split in 2 patches.

#4 lore raw
Quoted 10 lines · Thomas Monjalon

25/03/2020 15:11, Kevin Traynor:

Quoted 7 lines

This is a blunt way to remove this warning.

Some alternatives are:
- disable the warning for individual components
- components rework to statically allocate memory for parts of structs impacted

Maybe there's some other solutions?

In general, I am against disabling warnings, neither globally nor specifically.

Me too.

Quoted 2 lines

Is there a way to hide false positives without disabling the warning?

I haven't found one. If anyone has ideas it can be tested on Fedora 32 Beta which is available now, or I can try.

Quoted 13 lines
Quoted 13 lines

Impacted components:
../drivers/crypto/caam_jr/caam_jr_pvt.h
../drivers/crypto/ccp/ccp_crypto.h
../drivers/crypto/dpaa_sec/dpaa_sec.h
../drivers/crypto/virtio/virtio_cryptodev.h
../drivers/net/enic/base/vnic_dev.c
../drivers/net/iavf/../../common/iavf/virtchnl.h
../drivers/net/ice/base/ice_adminq_cmd.h
../drivers/net/mlx4/mlx4_rxtx.c
../drivers/net/qede/base/ecore_mcp.c
../lib/librte_cryptodev/rte_cryptodev.h
../lib/librte_pipeline/rte_table_action.c

Quoted 6 lines
Quoted 2 lines

Full details in the Bugzilla:
https://bugs.dpdk.org/show_bug.cgi?id=421

Would be easier to provide explanations here. I think we need at least one false positive example.

If we look at the iavf code for rss_key->key:

struct virtchnl_rss_key {
        u16 vsi_id;
        u16 key_len;
        u8 key[1];         /* RSS hash key, packed bytes */
        ^^^^^^^^^
};

Then in iavf_configure_rss_key()

	len = sizeof(*rss_key) + vf->vf_res->rss_key_size - 1;
                                             ^^^^^^^^^^^^
	rss_key = rte_zmalloc("rss_key", len, 0);
                  ^^^ extra space beyond key[1] allocated here

<snip>

	rte_memcpy(rss_key->key, vf->rss_key, vf->vf_res->rss_key_size);
	                    ^^^                           ^^^^^^^^^^^^

At runtime we have allocated extra space at the end of the struct for key, and the same size used in the malloc is also considered when finding the right branches in the memcpy fns. But the compiler does not know value of size and it simply sees there can be casts of a 1 byte key to 16 or 32 bytes in some branches of the memcpy fns, so gives a warning.

e.g. _mm256_storeu_si256((__m256i *)dst, ymm0);
That is: Store 256-bits of integer data into memory,
where key is dst so leads to: warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

Full log for warnings on key below.

Quoted 6 lines
Quoted 3 lines

Kevin Traynor (2):
meson: gcc 10 disable stringop-overflow warnings
mk: gcc 10 disable stringop-overflow warnings

You don't need to split in 2 patches.

ok, will change if it moves to PATCH.

Quoted 2 lines

In file included from /usr/lib/gcc/x86_64-redhat-linux/10/include/immintrin.h:51,
from
/usr/lib/gcc/x86_64-redhat-linux/10/include/x86intrin.h:32,
from
../lib/librte_eal/common/include/arch/x86/rte_vect.h:30,
from
../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:17,

                 from ../lib/librte_net/rte_ether.h:21,
                 from ../drivers/net/iavf/iavf_vchnl.c:18:

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_aligned’ at
../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2,
inlined from ‘iavf_configure_rss_key’ at
../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:867:10:
/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8: warning:
writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~
In file included from
../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10,
                 from ../drivers/net/iavf/iavf.h:9,
                 from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c: In function ‘iavf_configure_rss_key’:
../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5: note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~
In file included from
../lib/librte_eal/common/include/arch/x86/rte_atomic.h:15,
                 from ../drivers/net/iavf/iavf_vchnl.c:16:

In function ‘_mm_storeu_si128’,
inlined from ‘rte_memcpy_aligned’ at
../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:302:2,
inlined from ‘iavf_configure_rss_key’ at
../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:867:10:
/usr/lib/gcc/x86_64-redhat-linux/10/include/emmintrin.h:727:8: warning:
writing 16 bytes into a region of size 1 [-Wstringop-overflow=]

  727 |   *__P = __B;
      |   ~~~~~^~~~~
In file included from
../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10,
                 from ../drivers/net/iavf/iavf.h:9,
                 from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c: In function ‘iavf_configure_rss_key’:
../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5: note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~
#5 lore raw
Quoted 15 lines · On Tue, 31 Mar 2020 15:08:26 +0100 Kevin Traynor <[email protected]> wrote:
struct virtchnl_rss_key {
        u16 vsi_id;
        u16 key_len;
        u8 key[1];         /* RSS hash key, packed bytes */
        ^^^^^^^^^
};

Then in iavf_configure_rss_key()

	len = sizeof(*rss_key) + vf->vf_res->rss_key_size - 1;
                                             ^^^^^^^^^^^^
	rss_key = rte_zmalloc("rss_key", len, 0);
                  ^^^ extra space beyond key[1] allocated here

<snip>

Quoted 8 lines
	rte_memcpy(rss_key->key, vf->rss_key, vf->vf_res->rss_key_size);
	                    ^^^                           ^^^^^^^^^^^^

At runtime we have allocated extra space at the end of the struct for key, and the same size used in the malloc is also considered when finding the right branches in the memcpy fns. But the compiler does not know value of size and it simply sees there can be casts of a 1 byte key to 16 or 32 bytes in some branches of the memcpy fns, so gives a warning.

The standard way to do such a thing is to use an empty array. The Linux kernel has just gone through cleaning up all these zero length (and it this case one) array at end of function.

#6 lore raw
Quoted 27 lines · Stephen Hemminger
Quoted 15 lines · On Tue, 31 Mar 2020 15:08:26 +0100 Kevin Traynor <[email protected]> wrote:
struct virtchnl_rss_key {
        u16 vsi_id;
        u16 key_len;
        u8 key[1];         /* RSS hash key, packed bytes */
        ^^^^^^^^^
};

Then in iavf_configure_rss_key()

	len = sizeof(*rss_key) + vf->vf_res->rss_key_size - 1;
                                             ^^^^^^^^^^^^
	rss_key = rte_zmalloc("rss_key", len, 0);
                  ^^^ extra space beyond key[1] allocated here

<snip>

Quoted 8 lines
	rte_memcpy(rss_key->key, vf->rss_key, vf->vf_res->rss_key_size);
	                    ^^^                           ^^^^^^^^^^^^

At runtime we have allocated extra space at the end of the struct for key, and the same size used in the malloc is also considered when finding the right branches in the memcpy fns. But the compiler does not know value of size and it simply sees there can be casts of a 1 byte key to 16 or 32 bytes in some branches of the memcpy fns, so gives a warning.

Quoted 5 lines

The standard way to do such a thing is to use an empty array. The Linux kernel has just gone through cleaning up all these zero length (and it this case one) array at end of function.

Thanks for the tip. There is only one occurrence of a zero-length array in these warning (sess_data[0] in ice) and changing to [] does indeed remove the warning for that.

For the others they have a defined length so it cannot just be removed, some don't have any dynamic allocation at all, sizes are checked etc.

I don't think adding dynamic allocation for those structs just to get around this warning is the right way to go.

Crypto/iavf/ip_pipeline maintainers - any comment?

../drivers/crypto/caam_jr/caam_jr_pvt.h:187:10: note: at offset 0 to object ‘digest’ with size 32 declared here ../drivers/crypto/ccp/ccp_crypto.h:272:11: note: at offset 0 to object ‘key’ with size 32 declared here ../drivers/crypto/dpaa_sec/dpaa_sec.h:217:10: note: at offset 0 to object ‘digest’ with size 32 declared here ../drivers/crypto/virtio/virtio_cryptodev.h:36:10: note: at offset 0 to object ‘iv’ with size 16 declared here

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5: note: at offset 0 to object ‘key’ with size 1 declared here ../drivers/net/iavf/../../common/iavf/virtchnl.h:516:5: note: at offset 0 to object ‘lut’ with size 1 declared here

../lib/librte_pipeline/rte_table_action.c:1648:12: note: at offset 0 to object ‘cipher_iv’ with size 16 declared here ../lib/librte_pipeline/rte_table_action.c:1650:12: note: at offset 0 to object ‘auth_iv’ with size 16 declared here ../lib/librte_pipeline/rte_table_action.c:1655:12: note: at offset 0 to object ‘iv’ with size 16 declared here ../lib/librte_pipeline/rte_table_action.c:1656:12: note: at offset 0 to object ‘aad’ with size 16 declared here ../lib/librte_pipeline/rte_table_action.c:1728:10: note: at offset 0 to object ‘iv_aad_data’ with size 32 declared here

#7 lore raw

PATCH 1/1 build: gcc 10 disable stringop-overflow warnings

In reply to Kevin Traynor

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different implementations are used depending on the size. stringop-overflow is raised for the paths in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

Disable this warning at the top level as it is being raised on several components.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

Bugzilla ID: 394
Bugzilla ID: 421

---
 config/meson.build           | 3 ++-
 mk/toolchain/gcc/rte.vars.mk | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)
config/meson.build +2 -1
index 58421342b..476a667a9 100644
@@ -200,5 +200,6 @@ warning_flags = [
 	'-Wno-address-of-packed-member',
 	'-Wno-packed-not-aligned',
-	'-Wno-missing-field-initializers'
+	'-Wno-missing-field-initializers',
+	'-Wno-stringop-overflow'
 ]
 if not dpdk_conf.get('RTE_ARCH_64')
mk/toolchain/gcc/rte.vars.mk +3 -0
index f19305e49..fe4b8c705 100644
@@ -101,4 +101,7 @@ endif
 WERROR_FLAGS += -Wno-address-of-packed-member
 
+# disable stringop-overflow warnings
+WERROR_FLAGS += -Wno-stringop-overflow
+
 export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF
 export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS
Signature · 1 line
2.21.1
#8 lore raw

Re: [dpdk-dev] [PATCH] build: gcc 10 disable stringop-overflow warnings

Quoted 34 lines · Kevin Traynor

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different implementations are used depending on the size. stringop-overflow is raised for the paths in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

Disable this warning at the top level as it is being raised on several components.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

Quoted 8 lines

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

As an alternative, we could remove these warnings for rte_memcpy.h(s) only. WDYT?

(quoted diff) +0 -0

b/lib/librte_eal/x86/include/rte_memcpy.h
index ba44c4a32..862e0c402 100644

lib/librte_eal/x86/include/rte_memcpy.h +2 -0
@@ -19,4 +19,6 @@
 #include <rte_config.h>
 
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+
 #ifdef __cplusplus
 extern "C" {
Quoted 33 lines

Bugzilla ID: 394
Bugzilla ID: 421

---> config/meson.build | 3 ++-

 mk/toolchain/gcc/rte.vars.mk | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)
config/meson.build +2 -1
index 58421342b..476a667a9 100644
@@ -200,5 +200,6 @@ warning_flags = [
 	'-Wno-address-of-packed-member',
 	'-Wno-packed-not-aligned',
-	'-Wno-missing-field-initializers'
+	'-Wno-missing-field-initializers',
+	'-Wno-stringop-overflow'
 ]
 if not dpdk_conf.get('RTE_ARCH_64')
mk/toolchain/gcc/rte.vars.mk +3 -0
index f19305e49..fe4b8c705 100644
@@ -101,4 +101,7 @@ endif
 WERROR_FLAGS += -Wno-address-of-packed-member
 
+# disable stringop-overflow warnings
+WERROR_FLAGS += -Wno-stringop-overflow
+
 export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF
 export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS
#9 lore raw

Re: [dpdk-dev] [PATCH] build: gcc 10 disable stringop-overflow warnings

Quoted 53 lines · Kevin Traynor
Quoted 34 lines · Kevin Traynor

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different implementations are used depending on the size. stringop-overflow is raised for the paths in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

Disable this warning at the top level as it is being raised on several components.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

Quoted 8 lines

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

As an alternative, we could remove these warnings for rte_memcpy.h(s) only. WDYT?

lib/librte_eal/x86/include/rte_memcpy.h +0 -0
index ba44c4a32..862e0c402 100644

lib/librte_eal/x86/include/rte_memcpy.h line 24

Quoted 6 lines
lib/librte_eal/x86/include/rte_memcpy.h +2 -0
@@ -19,4 +19,6 @@
 #include <rte_config.h>
 
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+
 #ifdef __cplusplus
 extern "C" {

Limited disabling is always better than global disabling, so given the choice of the two, +1 for this.

/Bruce

#10 lore raw

Re: [dpdk-dev] [PATCH] build: gcc 10 disable stringop-overflow warnings

Quoted 56 lines · Bruce Richardson
Quoted 55 lines · Kevin Traynor
Quoted 34 lines · Kevin Traynor

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different implementations are used depending on the size. stringop-overflow is raised for the paths in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

Disable this warning at the top level as it is being raised on several components.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

Quoted 8 lines

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

As an alternative, we could remove these warnings for rte_memcpy.h(s) only. WDYT?

lib/librte_eal/x86/include/rte_memcpy.h +0 -0
index ba44c4a32..862e0c402 100644
@@ -19,4 +19,6 @@
 #include <rte_config.h>
 
Quoted 8 lines

lib/librte_eal/x86/include/rte_memcpy.h line 24

Quoted 4 lines
lib/librte_eal/x86/include/rte_memcpy.h +2 -0
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+
 #ifdef __cplusplus
 extern "C" {

Limited disabling is always better than global disabling, so given the choice of the two, +1 for this.

Thanks Bruce. The slight disadvantage of this approach in short term is a similar issue may also occur for gcc10 on ARM, but I don't have a setup to test that, so an additional arm/eal fix may be required later. I will limit fixing to what I can test, x86.

Gavin, can you check if a similar change is required for gcc10 on ARM?

Quoted 2 lines

/Bruce

#11 lore raw

PATCH v2 1/1 x86/eal: gcc 10 ignore stringop-overflow warnings

In reply to Kevin Traynor

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different branches are taken depending on the size. stringop-overflow is raised for the branches in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

Ignore the stringop-overflow warnings for rte_memcpy.h functions.

Bugzilla ID: 394
Bugzilla ID: 421

---

v2: Change from a global disable to just disabling for x86/rte_memcpy.h

---
 lib/librte_eal/x86/include/rte_memcpy.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/librte_eal/x86/include/rte_memcpy.h +4 -0
index ba44c4a32..283fb79ba 100644
@@ -23,4 +23,8 @@ extern "C" {
 #endif
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 100000)
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
+
 /**
  * Copy bytes from one location to another. The locations must not overlap.
Signature · 1 line
2.21.1
#12 lore raw

Re: [dpdk-dev] [PATCH v2] x86/eal: gcc 10 ignore stringop-overflow warnings

Quoted 58 lines · Kevin Traynor

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different branches are taken depending on the size. stringop-overflow is raised for the branches in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

Ignore the stringop-overflow warnings for rte_memcpy.h functions.

Bugzilla ID: 394
Bugzilla ID: 421

---

v2: Change from a global disable to just disabling for x86/rte_memcpy.h

---
 lib/librte_eal/x86/include/rte_memcpy.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/librte_eal/x86/include/rte_memcpy.h +0 -0
index ba44c4a32..283fb79ba 100644

lib/librte_eal/x86/include/rte_memcpy.h extern "C" { · line 30

Quoted 8 lines
lib/librte_eal/x86/include/rte_memcpy.h +4 -0
@@ -23,4 +23,8 @@ extern "C" {
 #endif
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 100000)
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
+
 /**
  * Copy bytes from one location to another. The locations must not overlap.

Does this permanently need to be disabled for all compilation units including rte_memcpy.h, or can it be used with a push/pop set of pragmas to only disable for the required functions?

#13 lore raw

Re: [dpdk-dev] [PATCH v2] x86/eal: gcc 10 ignore stringop-overflow warnings

17/04/2020 11:33, Bruce Richardson:

Quoted 46 lines · Kevin Traynor
Quoted 45 lines

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different branches are taken depending on the size. stringop-overflow is raised for the branches in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

Ignore the stringop-overflow warnings for rte_memcpy.h functions.

Bugzilla ID: 394
Bugzilla ID: 421

[...]

Quoted 9 lines

lib/librte_eal/x86/include/rte_memcpy.h extern "C" { · line 27

Quoted 5 lines
lib/librte_eal/x86/include/rte_memcpy.h +3 -0
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 100000)
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif

Does this permanently need to be disabled for all compilation units including rte_memcpy.h, or can it be used with a push/pop set of pragmas to only disable for the required functions?

Even better, isn't there a solution in memcpy code?

#14 lore raw

Re: [dpdk-dev] [PATCH v2] x86/eal: gcc 10 ignore stringop-overflow warnings

Quoted 58 lines · Thomas Monjalon

17/04/2020 11:33, Bruce Richardson:

Quoted 46 lines · Kevin Traynor
Quoted 45 lines

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different branches are taken depending on the size. stringop-overflow is raised for the branches in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

Ignore the stringop-overflow warnings for rte_memcpy.h functions.

Bugzilla ID: 394
Bugzilla ID: 421

[...]

Quoted 9 lines

lib/librte_eal/x86/include/rte_memcpy.h extern "C" { · line 27

Quoted 5 lines
lib/librte_eal/x86/include/rte_memcpy.h +3 -0
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 100000)
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif

Does this permanently need to be disabled for all compilation units including rte_memcpy.h, or can it be used with a push/pop set of pragmas to only disable for the required functions?

Quoted 3 lines

Even better, isn't there a solution in memcpy code?

There may be, it could do with fresh eyes - Bruce/Konstantin?

In the meantime I will send a v3 with push/pop so it is available as an option.

#15 lore raw

Re: [dpdk-dev] [PATCH v2] x86/eal: gcc 10 ignore stringop-overflow warnings

In reply to Bruce Richardson
Quoted 61 lines · Bruce Richardson
Quoted 60 lines · Kevin Traynor

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different branches are taken depending on the size. stringop-overflow is raised for the branches in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

Ignore the stringop-overflow warnings for rte_memcpy.h functions.

Bugzilla ID: 394
Bugzilla ID: 421

---

v2: Change from a global disable to just disabling for x86/rte_memcpy.h

---
 lib/librte_eal/x86/include/rte_memcpy.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/librte_eal/x86/include/rte_memcpy.h +0 -0
index ba44c4a32..283fb79ba 100644
@@ -23,4 +23,8 @@ extern "C" {
 #endif
 
Quoted 11 lines

lib/librte_eal/x86/include/rte_memcpy.h extern "C" { · line 30

Quoted 6 lines
lib/librte_eal/x86/include/rte_memcpy.h +4 -0
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 100000)
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
+
 /**
  * Copy bytes from one location to another. The locations must not overlap.

Does this permanently need to be disabled for all compilation units including rte_memcpy.h, or can it be used with a push/pop set of pragmas to only disable for the required functions?

Good point about compilation units. I'm not sure it makes sense to do per function as the only ones that won't need it are the mov64/128/256 that are just wrappers for mov16/32 etc. Every function in rte_memcpy.h that uses intrinsics and the aligned/generic will likely need it, which is almost all of them.

With the GCC version conditional wrappers along with multiple implementations depending on CPUFLAGS per function becomes messy and harder to test. Considering that adding push/pop for the file only increases the scope to those wrapper functions, I think it is better to push/pop for the file.

#16 lore raw

PATCH v3 1/1 x86/eal: gcc 10 ignore stringop-overflow warnings

In reply to Kevin Traynor

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different branches are taken depending on the size. stringop-overflow is raised for the branches in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

      |     ^~~

Ignore the stringop-overflow warnings for rte_memcpy.h functions.

Bugzilla ID: 394
Bugzilla ID: 421

---
v3: Add push/pop to not leak the ignore warning
v2: Change from a global disable to just disabling for x86/rte_memcpy.h

---
 lib/librte_eal/x86/include/rte_memcpy.h | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/librte_eal/x86/include/rte_memcpy.h +9 -0
index ba44c4a32..9c67232df 100644
@@ -23,4 +23,9 @@ extern "C" {
 #endif
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 100000)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
+
 /**
  * Copy bytes from one location to another. The locations must not overlap.
@@ -870,4 +875,8 @@ rte_memcpy(void *dst, const void *src, size_t n)
 }
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 100000)
+#pragma GCC diagnostic pop
+#endif
+
 #ifdef __cplusplus
 }
Signature · 1 line
2.21.1
Acked-by Bruce Richardson Acked-by Konstantin Ananyev on v3 1/1 Applied
#17 lore raw

Re: [dpdk-dev] [PATCH v3] x86/eal: gcc 10 ignore stringop-overflow warnings

Quoted 38 lines · Kevin Traynor

stringop-overflow warns when it sees a possible overflow in a string operation.

In the rte_memcpy functions different branches are taken depending on the size. stringop-overflow is raised for the branches in the function where it sees the static size of the src could be overflowed.

However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen.

For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised.

In function ‘_mm256_storeu_si256’,
inlined from ‘rte_memcpy_generic’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from ‘iavf_configure_rss_key’
at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10:

/usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8:
warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow=]

  928 |   *__P = __A;
      |   ~~~~~^~~~~

In file included
from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9,
from ../drivers/net/iavf/iavf_vchnl.c:22:

../drivers/net/iavf/iavf_vchnl.c:
In function ‘iavf_configure_rss_key’:

../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5:
note: at offset 0 to object ‘key’ with size 1 declared here
508 | u8 key[1]; /* RSS hash key, packed bytes */

Quoted 7 lines
      |     ^~~

Ignore the stringop-overflow warnings for rte_memcpy.h functions.

Bugzilla ID: 394
Bugzilla ID: 421

Quoted 1 line

Applied, thanks.

Signature · 1 line
David Marchand