Skip to content

Commit a5e0ace

Browse files
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. Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/lkml/[email protected]/ Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/linux-hardening/ZWj1+jkweEDWbmAR@work/ Signed-off-by: Gustavo A. R. Silva <[email protected]>
1 parent 113a618 commit a5e0ace

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,9 @@ NOSTDINC_FLAGS += -nostdinc
986986
# perform bounds checking.
987987
KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
988988

989-
KBUILD_CFLAGS += $(call cc-option, -Wstringop-overflow)
989+
#Currently, disable -Wstringop-overflow for GCC 11, globally.
990+
KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
991+
KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
990992

991993
# disable invalid "can't wrap" optimizations for signed / pointers
992994
KBUILD_CFLAGS += -fno-strict-overflow

init/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,18 @@ config CC_NO_ARRAY_BOUNDS
876876
bool
877877
default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC11_NO_ARRAY_BOUNDS
878878

879+
# Currently, disable -Wstringop-overflow for GCC 11, globally.
880+
config GCC11_NO_STRINGOP_OVERFLOW
881+
def_bool y
882+
883+
config CC_NO_STRINGOP_OVERFLOW
884+
bool
885+
default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC_VERSION < 120000 && GCC11_NO_STRINGOP_OVERFLOW
886+
887+
config CC_STRINGOP_OVERFLOW
888+
bool
889+
default y if CC_IS_GCC && !CC_NO_STRINGOP_OVERFLOW
890+
879891
#
880892
# For architectures that know their GCC __int128 support is sound
881893
#

0 commit comments

Comments
 (0)