Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp595753rdb; Thu, 30 Nov 2023 12:52:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHI7JfkKrgbTSXh6S1Ilb4r62o0XpLX7QxxuqlIAwmHIOunPSXUL3O4Zyteb5R6wkcnwpRy X-Received: by 2002:a17:902:dacf:b0:1cf:edd5:f786 with SMTP id q15-20020a170902dacf00b001cfedd5f786mr14029782plx.21.1701377541550; Thu, 30 Nov 2023 12:52:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701377541; cv=none; d=google.com; s=arc-20160816; b=nj8/RWPa/rqC6M/WiEfJ02aa4Ytyd55s4uAANLZHur32fSPAx0XOnGPCeP09eP5EB0 zVmyz390KnrIOy/EOlFoU74v2QAr9NfT1VQ8Rf3Z12EB93OncpBfGEf4B2OCn2QMA1C5 rtgXKDuBijqkiVOTn/iLsYz2b5GljMScnSzzr3q1Maequ/fUjXk6clCTZrmhoKDV+8Bb VS0X7JUWwXf+hQyaELZPDpgRnhH2N9NP5vEGYWLmiVlGv74scfxXDtKYYyX/JCQAp4NV ILZqLAMxU81GAlQxUs9CWY1qoPu/U/KPDpYgnHbu9Irf9+yxaw98jkqkSreC1JeIAx/D dPeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=Hv4NFoQr+9X8ZU/5W8HhpKFh+4XO723+qPsT/la66iA=; fh=iWFqK9bmStdVNH0hw6imcXKSM5BTnovcF/desFxY6JA=; b=B6M+qPAFZKUyq/a5/e+3ImIzunvhoKvnWrafwHu6McrcGroiydTZ7Ot+sLXtqZ5bf8 dgMN5NBkwiaqr2P4qM2gKbJoRkZID2bmCSopNVRYIzzazj5ac3d974KLZ3nkkHI1dkJk 8nKy5BJ3glxMK4ZtTdQHnN2i4V1RShJpb+KdjQKhpaJ1VAuDfNwA6bY9kil0nQqDZZ5+ Gk6EhhSESVMoG+a+Mausp2eFI+1T6ZXFds+Bj8qF2G4cTntDWdwxsJ1S4s+FOO7XQ0OR 6590WjDKNp2dYn1zw1Rh9H60WfyYXfuqxK6D+7HMZla++5QrO+LHedBtJDQiA4w15NGy tffQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PH9L32LD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id p1-20020a1709028a8100b001cfbf5c0466si1830312plo.22.2023.11.30.12.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:52:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PH9L32LD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4B68280D6E4E; Thu, 30 Nov 2023 12:52:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376408AbjK3UwJ (ORCPT + 99 others); Thu, 30 Nov 2023 15:52:09 -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-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 12:52:19 -0800 (PST) -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 --- 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 += -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 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 >= 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 # -- 2.34.1