Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1414727pxb; Tue, 17 Aug 2021 11:05:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUujmlgmS9B/pEQPQfNcj6ocjsHQWl0as/Y3wC0Wujwv/5UJvJVkf3DJBPx/zsF9uszrJt X-Received: by 2002:a02:b68c:: with SMTP id i12mr3961175jam.31.1629223517932; Tue, 17 Aug 2021 11:05:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629223517; cv=none; d=google.com; s=arc-20160816; b=aEsGWjRnWxpeXUhogpxj6/WvKFJw2bjI+KOn3dYr/xU3QSCyxsFaxFWtNabrFvOm0h isMEnDiCiS+UnyLuIChFYCiyU/3M4y0NO7abROJzcUUgqX77AterNvUF3uel0Os5LxV9 j+xYyTd7AXw9q8oBmjutT97NrzXi/rB1R098tiKKGnm28lddko1XBSw809GEbzdT2k2X rZEt+rQSZ1qTisHwDOICyRfya4WCZoFse5Q6QtAREbdZdyPoHJXQLNRH0+5JM/VyWNsN JKSpq+mMgrzvUyuWk1kqL2QNIV/ipRAGZGyxllK07kbzmlbFLZjksRyLgrENKG3/Wpqm zkyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6lswvnaMe+F2ActgzyrTI+M1fqtFvqoQVjkUc9W7PnY=; b=hrUyGtoeWb+zoiW9w4+/c6KCMqjfB6D9oM790H0Sg1IexJIAOfwbnia7GeBXxqGTck PsSThNnA7cMhLZf4ukGOqUtOkhSc8ELmWT+8n/xTsflbNz01tnldv7H/oNdVmijZUUJX AMWwalstVtxI+ZdvyyT06RSTiT5QLYofT6oSaAC4rJKiHbEkghRj2tEmzsbfsSEVusQe FXrxYegDliB1czftVhz+TQdstybjAnKC8OIpwVX31RbLATxQor5fBqDJN339bzzj/cdq 58CNIPcfyBCY8EQJeyYxIPIr9CxkPGurbjNntkWgSdOowLuAukGYTJ9ntKYe867iO7mT I5zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hc7K+Fgw; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t24si2638357iol.88.2021.08.17.11.05.03; Tue, 17 Aug 2021 11:05:17 -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=@chromium.org header.s=google header.b=hc7K+Fgw; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232508AbhHQSDl (ORCPT + 99 others); Tue, 17 Aug 2021 14:03:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232294AbhHQSDj (ORCPT ); Tue, 17 Aug 2021 14:03:39 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EA1C0613CF for ; Tue, 17 Aug 2021 11:03:06 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id u21-20020a17090a8915b02901782c36f543so6575135pjn.4 for ; Tue, 17 Aug 2021 11:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6lswvnaMe+F2ActgzyrTI+M1fqtFvqoQVjkUc9W7PnY=; b=hc7K+FgwfduIEmInLkmKx4tsC08A3U83T2TJQO0/iX6/ecQCNh13QQgvwv0g0aZr1P C/PhRqHCrMbqua/jd3Gqrx5zn7Ac6f0ZVGmGYVnGq0D+l/CJHNWvNk//tMBgWo7EHI+1 uVPiSbNmQcPMA1daymyGJxIa1nRAl4BzsDXq8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6lswvnaMe+F2ActgzyrTI+M1fqtFvqoQVjkUc9W7PnY=; b=ipLxxG8rATDKK/z7S/a4cbG6LbCO1zkSCVp2Ela6ozWsC6kofWhMzoohA80/hVKMpG FEumFWWAEP0TeG1bvosWve3CaLMfw7bILBsSoNalg/wq+1HlDoX5ddDJz2ZabrkJ3BZx Knl59qRK2oHNhHMkR9vbuIO8J7piXME/KrvTcupnes6E3+NYaPzsSHlMiU8G6pI9QLlI Z9nSJbuazWR432io2XFszmduaJNM+nOB2Xn49kQJzvei2YzfJNhTbIs7yJVjMUMVfg+i Tz+DgIF0w1gvQbgvac6xmVZr5C1Vcs7n0B5IWoQNILVgZzPpNMG9jDMYc/m+74un8zup s6ZQ== X-Gm-Message-State: AOAM530wip+AJtO2kg/bQ8uJtMUH7/YxQypAgTVP3ZRag2CO5pw5ihF2 REoBP/RA4Du5bu7ayxYTfarKeg== X-Received: by 2002:a65:6398:: with SMTP id h24mr4682422pgv.367.1629223386078; Tue, 17 Aug 2021 11:03:06 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g2sm3325769pfi.211.2021.08.17.11.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 11:03:05 -0700 (PDT) Date: Tue, 17 Aug 2021 11:03:03 -0700 From: Kees Cook To: Nathan Chancellor 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 Subject: Re: [PATCH] kbuild: Enable -Wimplicit-fallthrough for clang 14.0.0+ Message-ID: <202108171056.EDCE562@keescook> References: <20210817005624.1455428-1-nathan@kernel.org> <80fa539a-b767-76ed-dafa-4d8d1a6b063e@kernel.org> <5c856f36-69a7-e274-f72a-c3aef195adeb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5c856f36-69a7-e274-f72a-c3aef195adeb@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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): 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 -- Kees Cook