From patchwork Thu Nov 30 20:52:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 172122 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp676851vqy; Thu, 30 Nov 2023 12:52:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6kTeS1FtAZBRjY2HH5yVaYDUtWdKmOgHzyjgsCSvF8dE2a3xeIQds+gHl85sp9rxyk9iy X-Received: by 2002:a05:6a20:1614:b0:18b:f108:1595 with SMTP id l20-20020a056a20161400b0018bf1081595mr23851967pzj.53.1701377541022; 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 Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q145-20020a632a97000000b005a9b0fe6afbsi2086753pgq.144.2023.11.30.12.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:52:20 -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 7B0CE80236FA; Thu, 30 Nov 2023 12:52:18 -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-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:18 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784023656397866947 X-GMAIL-MSGID: 1784023656397866947 -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 += -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 #