Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5574376pxb; Mon, 14 Feb 2022 02:21:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxr0zTAEy4jSSUcKHaQvY+XSuA/q/1bbMjIUQH5ZfxKtNcr9YEFRbRjuVdBDUQdI1voPAtm X-Received: by 2002:a17:90b:1e04:: with SMTP id pg4mr13805155pjb.21.1644834089643; Mon, 14 Feb 2022 02:21:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644834089; cv=none; d=google.com; s=arc-20160816; b=wuLt+ea6XLHWHKzjObSMA1wyMQg5LJ8g5S16IB/Pr3icuxlh7JezCi7SuU8vEjLE4O 3kuBhYExjOnnOvv8D1RubCgWFK2zv3217BZsiLrYfGTaCe6VlSPlNuzKpfK2mArWuzKS pqOpoNvUN3BUieaYVz56b0+DAv1y/A3ldWXZ/+Uf1yTAwXGTAmhoZ0sAm236i+nR5Dzq 7HH0M+MdFMMgrVnujgvIVrT/6vdwOoGwf2QWjA/2oHhoCoHQERmgoBiD4wbO4DeMk/Ly 37NCpagyzefC3hb6vLHlQubMctGFnC1qK8gGAXN23H+jZliGHMjOeuQYIZ1O2N15TeeO AjRQ== 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=7VKg0zjQwSALdbTIf5uSsnkD9DpXhrHD5gjop/xM2cY=; b=N8Ui/fo4xCELyeAQTRCXWpAeQr2KeKucv7QIJSEctFYAy9iGcJAclJEotIcKtgjpUD qvqE7H48z2MGtzTvTg+b+SCFLwpq/zJm6yyMwBqmmjQK3+3qKjXnhU/xxJ2Z0mBp/SVc ZZ5d8cr9Rb+a9+MGCR3/nrgnPPQzmy0PQgKKe4vZxHIhlNXqhKbhBFB7qSMeB+fSTIu2 SbSsakqw3mBRuB2LpLG5KHT7htWfcdOxMFGSXlgTyRK4iCiQbTPTOxC/3I/Wt8hI70h8 KsM2ftXAZXamn0+jn/eEeg7dm+PfVusG1o0NTgAMAE3xrL2H0BSUf4L/AIK+jKCQrTEF immg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="fVgW/+nj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e125si3746646pgc.165.2022.02.14.02.21.17; Mon, 14 Feb 2022 02:21:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="fVgW/+nj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1354438AbiBLAhx (ORCPT + 93 others); Fri, 11 Feb 2022 19:37:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:39208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354419AbiBLAhx (ORCPT ); Fri, 11 Feb 2022 19:37:53 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A1D8D6 for ; Fri, 11 Feb 2022 16:37:51 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id v4so9502835pjh.2 for ; Fri, 11 Feb 2022 16:37:51 -0800 (PST) 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=7VKg0zjQwSALdbTIf5uSsnkD9DpXhrHD5gjop/xM2cY=; b=fVgW/+njctwyhjA00T4OTwKIyHC+ekd/gR2K1kuA66oeEQXIkPL1FXYiyWdAp1d0xn TbdfWzdca4NFtjxnNV2QMdmjjW4SM+aVVim50VDMFKC4dYF/vTsoAHkeValgFgcoC+S3 UO2HQ51kQVncYNuzO0ANIFL2p5kuevmP5FdQc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7VKg0zjQwSALdbTIf5uSsnkD9DpXhrHD5gjop/xM2cY=; b=YqcNnh814BoDtfKbE5nmzjcvnYEpjOCWczlw50YejRtcUGVy3NefVB+cMX7YuijR4M szavYRxLnwkp5GKRZyS2UA2myowg5ozHYlNvZ+KrijztIYmd9si8LR5nE4bRwGO1qTRP 2OkStEdvoGxRKj+op6/YMedCsl/fSh9uDi6ML0Ue+JUgpZI5bsltBL94OD6oab+deY8g BW5uo1/f+/ZJi/zU+aopxieMGbZxkpC+MJUSuYfLavHjNmxiVFQEUdH/X7X8qXKDRB7a B5tkTmJ0yv6lWWHVlvlEr0gRw717njnsI21KTA92yupCC9+h7FNJiV6EfPIbRtD1iBPh HQ8Q== X-Gm-Message-State: AOAM531l9BEsDi4WjsTP9wsttvZ41Y5FztNIitmSAVIa/+TFmijw0a4s f8Cp89Mz55m3VwCFxVkjM5SFGQ== X-Received: by 2002:a17:90a:1a53:: with SMTP id 19mr2970043pjl.19.1644626270083; Fri, 11 Feb 2022 16:37:50 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h26sm20567050pgm.72.2022.02.11.16.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 16:37:49 -0800 (PST) Date: Fri, 11 Feb 2022 16:37:48 -0800 From: Kees Cook To: Robin Murphy Cc: Ard Biesheuvel , Victor Erminpour , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , "Rafael J. Wysocki" , Len Brown , ACPI Devel Maling List , Linux ARM , Linux Kernel Mailing List , trivial@kernel.org Subject: Re: [PATCH v2] ACPI/IORT: Fix GCC 12 warning Message-ID: <202202111623.A7881CC@keescook> References: <1644518851-16847-1-git-send-email-victor.erminpour@oracle.com> <202202101415.43750CEE@keescook> <3740c93e-9fde-f89f-9752-26ffff3ea274@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3740c93e-9fde-f89f-9752-26ffff3ea274@arm.com> 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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Fri, Feb 11, 2022 at 10:34:09AM +0000, Robin Murphy wrote: > Hi Kees, > > On 2022-02-10 23:47, Kees Cook wrote: > > On Thu, Feb 10, 2022 at 08:41:51PM +0100, Ard Biesheuvel wrote: > > > On Thu, 10 Feb 2022 at 19:48, Victor Erminpour > > > wrote: > > > > > > > > When building with automatic stack variable initialization, GCC 12 > > > > complains about variables defined outside of switch case statements. > > > > Move the variable into the case that uses it, which silences the warning: > > > > > > > > ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable] > > > > 1670 | struct acpi_iort_named_component *ncomp; > > > > | ^~~~~ > > > > > > > > Signed-off-by: Victor Erminpour > > > > > > Please cc people that commented on your v1 when you send a v2. > > > > > > Still NAK, for the same reasons. > > > > Let me see if I can talk you out of this. ;) > > > > So, on the face of it, I agree with you: this is a compiler bug. However, > > it's still worth fixing. Just because it's valid C isn't a good enough > > reason to leave it as-is: we continue to minimize the subset of the > > C language the kernel uses if it helps us get the most out of existing > > compiler features. We've eliminated all kinds of other "valid C" from the > > kernel because it improves robustness, security, etc. This is certainly > > nothing like removing VLAs or implicit fallthrough, but given that this > > is, I think, the only remaining case of it (I removed all the others a > > while ago when I had the same issues with the GCC plugins), I'd like to > > get it fixed. > > It concerns me if minimising the subset of the C language that the kernel > uses is achieved by converting more of the kernel to a not-quite-C language > that is not formally specified anywhere, by prematurely adopting > newly-invented compiler options that clearly don't work properly (the GCC > warning message quoted above may as well be "error: giraffes are not purple" > for all the sense it makes.) Yeah, you're right. While it's a corner case, it's still important to get it fixed because it risks eroding people's good will for future work. What you (and Ard) bring up is just as important a roadblock as any of the other (many *sob*) roadblocks that have been overcome for its adoption. > From your security standpoint (and believe me, I really do have faith in > your expertise here), which of these sounds better: > > 1: Being able to audit code based on well-defined language semantics > > 2: Playing whack-a-mole as issues are discovered empirically. > > 3: Neither of the above, but a warm fuzzy feeling because hey someone said > "security" in a commit message. > > AFAICS you're effectively voting against #1, and the examples you've given > demonstrate that #2 is nowhere near reliable enough either, so where does > that leave us WRT actual secure and robust code in Linux? Well, I'm for #1, though perhaps with a more narrow view: some semantics are just weird/surprising. ;) Until I first encountered this warning a few years ago when working on GCC_PLUGIN_STRUCTLEAK_BYREF_ALL, I didn't even know putting declarations there was valid C. ;) Whack-a-mole is part of the work to make these kinds of treewide changes, but the hope is to find as much of it ahead of time as possible. And, no, I have no interest in security theater. (Not everything has equal levels of effectiveness, of course, but I don't think that's what you're saying.) > In fairness I'd have no objection to that patch if it came with a convincing > justification, but that is so far very much lacking. My aim here is not to > be a change-averse Luddite, but to try to find a compromise where I can > actually have some confidence in such changes being made. Let's not start > pretending that 3 100ml bottles of shampoo are somehow "safer" than a 300ml > bottle of shampoo... Sure. I think I am trying to take a pragmatic approach here, which is that gaining auto-var-init is a big deal (killing entire classes of vulnerabilities), but it comes with an annoying compiler bug (that we do get a warning about) for an uncommon code pattern that is easy to fix. So rather than delaying the defense until the sharp edge on the compiler gets fixed, I'd like to get the rest rolling while the edge is filed. -Kees -- Kees Cook