From nobody Tue Dec 16 16:37:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81B1EC4167B for ; Thu, 30 Nov 2023 20:52:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376755AbjK3UwK (ORCPT ); Thu, 30 Nov 2023 15:52:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376386AbjK3UwI (ORCPT ); Thu, 30 Nov 2023 15:52:08 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06526D54 for ; Thu, 30 Nov 2023 12:52:14 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64B17C433C7; Thu, 30 Nov 2023 20:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701377534; bh=R7LNuLwRzlt/17e18V7R1EEOuUFGqpcWy3MHGj0x6iM=; h=Date:From:To:Cc:Subject:From; b=PH9L32LDTUo5YBVfdO+i974H6l5nZItyapR+AsLpeoGzf/+dGCu1c+X+ivz0qgAhv +ubaCZfQPmAeHFtWPvxjrYsyh8V0OvLWxCfqKemE0TiBLk02sCZqL65asc3cPEz/9t KAT/mFR7jEEK8re5RUp3wiVeqEIDk9V9LU9zz17+5drCadHLfMdB18Q9ndgkdF+uku ImJYlkGfUNJvFioVreeYdyiVIcczEMuV+ZhFF6y1+hSwDx5p+IrMUcF8X7vDRt51M5 6JB4ng2ylWAtNJxDcQGXioxeERJhmYABsjgkx2EecpJs0NnW2DCHpRgTUUN5u38X3l IpQI2NCEwvZlA== Date: Thu, 30 Nov 2023 14:52:10 -0600 From: "Gustavo A. R. Silva" To: Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Kees Cook Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] init: Kconfig: Disable -Wstringop-overflow for GCC-11 Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" -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. Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- Makefile | 4 +++- init/Kconfig | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2cfd71ae3a86..8adc611fb611 100644 --- a/Makefile +++ b/Makefile @@ -982,7 +982,9 @@ NOSTDINC_FLAGS +=3D -nostdinc # perform bounds checking. KBUILD_CFLAGS +=3D $(call cc-option, -fstrict-flex-arrays=3D3) =20 -KBUILD_CFLAGS +=3D $(call cc-option, -Wstringop-overflow) +#Currently, disable -Wstringop-overflow for GCC 11, globally. +KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) +=3D $(call cc-option, -Wn= o-stringop-overflow) +KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) +=3D $(call cc-option, -Wstri= ngop-overflow) =20 # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS +=3D -fno-strict-overflow diff --git a/init/Kconfig b/init/Kconfig index 9ffb103fc927..aaaa99a5d2a9 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -876,6 +876,18 @@ config CC_NO_ARRAY_BOUNDS bool default y if CC_IS_GCC && GCC_VERSION >=3D 110000 && GCC11_NO_ARRAY_BOUNDS =20 +# 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 >=3D 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 # --=20 2.34.1