Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1431526pxb; Tue, 17 Aug 2021 11:29:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWJ2VSqFFl18U+7qha0uh9+ayvf0OXUnbuQ9xxw74S8frm57autgdbmI5UCDcCVcuRZGai X-Received: by 2002:aa7:c49a:: with SMTP id m26mr5768330edq.258.1629224990908; Tue, 17 Aug 2021 11:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629224990; cv=none; d=google.com; s=arc-20160816; b=izBfzB4YL8Q06+jDSGDV3DlTqltwCvQVqjuQB00HaywRnVXLdOLe+4OAMnJeJne4lv wtHJ2N4FrLl7M46HU6gtytTkIgxr/Y0Q/jKbw6DZmv8qFWNURomUiriegYXhU25MPiyp GemK4C3A/iZIu2fTPiz07tBLc0dFyq2G3IIDEf14Y2Z3790fZYqPgg6CRPhvKbr73Qk0 5xqBXylN1D/eFVPliVebcJpdJ9oGd5Zaifq4VVjVuZJ8iRGI1Y+dJFAKwZUZVVemV4dd c6sW4B4DyLOQPgPUn6ntlD9CAx96R9kz5qkXPAqYxkE2wFRXNRT9S1nI8EYi+K2imaBv mJIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=DOVX/oFvrEr1yoGGSkepp1V2jv/aOK/FCzOvgtXevjs=; b=wjuwZ54319Anrn95B4b5+/SoUW0S8NetWrqPk+nf4IEq2RMc2TNCS1QEfUBm3v+m5f rUDFT/ptzgvljh9HW8DuWFH37dHXi8Wzga2+f8vjt/crElwJr/lCyRoGi51Yp2eqTFF0 g5X+81ReMczYkP+lH4F/ZCLV55RsU3+MkIf2s+5bX3q9W4srr7iO201qKqKh9csZfBif OHruDI547kB325reGUsgcM5AgYDaNsXiFoT1+lpkxXLX14I8I6TsYAmCJWZwRdH6oB81 nXmmPPLJq8DPW8vLGQcB2MRpKr+i0AdLWNkIKpUtxlnHZzWc+V0AjkJ6KK0+FpgDZPag bgog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZToh53CS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k4si2959566ejx.135.2021.08.17.11.29.26; Tue, 17 Aug 2021 11:29:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZToh53CS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232620AbhHQS0M (ORCPT + 99 others); Tue, 17 Aug 2021 14:26:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:47200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbhHQS0M (ORCPT ); Tue, 17 Aug 2021 14:26:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD4F461042; Tue, 17 Aug 2021 18:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629224738; bh=nWbbMoPYSmgWbb9ggWGwm0E2EwA2A5FEXfoy+4Gdimw=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=ZToh53CS+k4whLQV1F3538RG4BEuDg3v5Clog2vY7FUUUhCXpnxDJSU2hblfP9UzG ql7draPX+GJLCdfL533uAvHXroLbocssLDFufvuhfhXUl2VcrbXSqUfkvEXRSwjF1l dA9JawlgiWXnNhjNcUgSieAodpgO7vfC/urS0kzablCR6IdRJJqyXKYa0pntt4yjz5 deNi/Goj1H3nlnVVfR1c4LEO/qWRTvYRrNeqcqMA/irH7ABePp5Tcj03WCBz1RmY5R JP4RebhR9L2DO7bAIFG0qFOeRBtPGb7p0mLt7scXhbCRZHPwABgN+lzau/XhtyZMQj PHmSXScRnS1Uw== Subject: Re: [PATCH] kbuild: Enable -Wimplicit-fallthrough for clang 14.0.0+ To: Kees Cook Cc: Linus Torvalds , "Gustavo A. R. Silva" , Nick Desaulniers , Masahiro Yamada , Linux Kbuild mailing list , Linux Kernel Mailing List , clang-built-linux , linux-hardening@vger.kernel.org References: <20210817005624.1455428-1-nathan@kernel.org> <80fa539a-b767-76ed-dafa-4d8d1a6b063e@kernel.org> <5c856f36-69a7-e274-f72a-c3aef195adeb@kernel.org> <202108171056.EDCE562@keescook> From: Nathan Chancellor Message-ID: <3f28b45e-e725-8b75-042a-d34d90c56361@kernel.org> Date: Tue, 17 Aug 2021 11:25:36 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <202108171056.EDCE562@keescook> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/17/2021 11:03 AM, Kees Cook wrote: > On Mon, Aug 16, 2021 at 09:55:28PM -0700, Nathan Chancellor wrote: >> If you/Gustavo would prefer, I can upgrade that check to >> >> ifneq ($(call cc-option, -Wunreachable-code-fallthrough),) >> >> I was just trying to save a call to the compiler, as that is more expensive >> than a shell test call. > > I prefer the option test -- this means no changes are needed on the > kernel build side if it ever finds itself backported to earlier versions > (and it handles the current case of "14" not meaning "absolute latest"). > > More specifically, I think you want this (untested): That should work but since -Wunreachable-code-fallthrough is off by default, I did not really see a reason to include it in KBUILD_CFLAGS. I do not have a strong opinion though, your version is smaller than mine is so we can just go with that. I'll defer to Gustavo on it since he has put in all of the work cleaning up the warnings. Cheers, Nathan > diff --git a/Makefile b/Makefile > index b5fd51e68ae9..9845ea50a368 100644 > --- a/Makefile > +++ b/Makefile > @@ -859,11 +859,11 @@ KBUILD_CFLAGS += -Wno-gnu > # source of a reference will be _MergedGlobals and not on of the whitelisted names. > # See modpost pattern 2 > KBUILD_CFLAGS += -mno-global-merge > +# Warn about unmarked fall-throughs in switch statement only if we can also > +# disable the bogus unreachable code warnings. > +KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough -Wno-unreachable-code-fallthrough,) > else > - > # Warn about unmarked fall-throughs in switch statement. > -# Disabled for clang while comment to attribute conversion happens and > -# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed. > KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=5,) > endif > >