init: Kconfig: Disable -Wstringop-overflow for GCC-11
PATCH 1/1 init: Kconfig: Disable -Wstringop-overflow for GCC-11
-Wstringop-overflow is buggy in GCC-11. Therefore, we should disable this option specifically for that compiler version. To achieve this, we introduce a new configuration option: GCC11_NO_STRINGOP_OVERFLOW.
The compiler option related to string operation overflow is now managed under configuration CC_STRINGOP_OVERFLOW. This option is enabled by default for all other versions of GCC that support it.
--- Makefile | 4 +++- init/Kconfig | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +3 -1
@@ -982,7 +982,9 @@ NOSTDINC_FLAGS += -nostdinc # perform bounds checking. KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3) -KBUILD_CFLAGS += $(call cc-option, -Wstringop-overflow) +#Currently, disable -Wstringop-overflow for GCC 11, globally. +KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow) +KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow) # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += -fno-strict-overflow
init/Kconfig +12 -0
@@ -876,6 +876,18 @@ config CC_NO_ARRAY_BOUNDS bool default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC11_NO_ARRAY_BOUNDS +# Currently, disable -Wstringop-overflow for GCC 11, globally. +config GCC11_NO_STRINGOP_OVERFLOW + def_bool y + +config CC_NO_STRINGOP_OVERFLOW + bool + default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC_VERSION < 120000 && GCC11_NO_STRINGOP_OVERFLOW + +config CC_STRINGOP_OVERFLOW + bool + default y if CC_IS_GCC && !CC_NO_STRINGOP_OVERFLOW + # # For architectures that know their GCC __int128 support is sound #
Signature · 1 line
2.34.1
Quoted 1 line · Gustavo A. R. Silva
-Wstringop-overflow is buggy in GCC-11. Therefore, we should disable
Can you add some links for this? For example, maybe this?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490
Or discussions from -next builds?
Quoted 8 lines
this option specifically for that compiler version. To achieve this, we introduce a new configuration option:
GCC11_NO_STRINGOP_OVERFLOW.The compiler option related to string operation overflow is now managed under configuration
CC_STRINGOP_OVERFLOW. This option is enabled by default for all other versions of GCC that support it.Signed-off-by Gustavo A. R. Silva <[email protected]>
But yeah, let's get this landed to keep new warnings from appearing...
Quoted 46 lines
--- Makefile | 4 +++- init/Kconfig | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)Makefile +3
-1@@ -982,7 +982,9 @@ NOSTDINC_FLAGS += -nostdinc # perform bounds checking. KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3) -KBUILD_CFLAGS += $(call cc-option, -Wstringop-overflow) +#Currently, disable -Wstringop-overflow for GCC 11, globally. +KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow) +KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow) # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += -fno-strict-overflowinit/Kconfig +12
-0@@ -876,6 +876,18 @@ config CC_NO_ARRAY_BOUNDS bool default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC11_NO_ARRAY_BOUNDS +# Currently, disable -Wstringop-overflow for GCC 11, globally. +config GCC11_NO_STRINGOP_OVERFLOW + def_bool y + +config CC_NO_STRINGOP_OVERFLOW + bool + default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC_VERSION < 120000 && GCC11_NO_STRINGOP_OVERFLOW + +config CC_STRINGOP_OVERFLOW + bool + default y if CC_IS_GCC && !CC_NO_STRINGOP_OVERFLOW + # # For architectures that know their GCC __int128 support is sound #Signature · 1 line
2.34.1
Signature · 1 line
Kees Cook
Quoted 7 lines · Kees Cook
Quoted 1 line · Gustavo A. R. Silva
-Wstringop-overflow is buggy in GCC-11. Therefore, we should disable
Can you add some links for this? For example, maybe this?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490Or discussions from -next builds?
Done. :)
Quoted 4 lines
Quoted 4 lines
this option specifically for that compiler version. To achieve this, we introduce a new configuration option:
GCC11_NO_STRINGOP_OVERFLOW.
Quoted 8 lines
Quoted 5 lines
The compiler option related to string operation overflow is now managed under configuration
CC_STRINGOP_OVERFLOW. This option is enabled by default for all other versions of GCC that support it.Signed-off-by Gustavo A. R. Silva <[email protected]>But yeah, let's get this landed to keep new warnings from appearing...
I just applied this to my -next tree.
Quoted 1 line
Reviewed-by Kees Cook <[email protected]>
Thanks!
--
Gustavo