Received: by 2002:a19:ef0c:0:0:0:0:0 with SMTP id n12csp950277lfh; Tue, 1 Feb 2022 12:51:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAL2cfR8bvEd8hRbmo/o5HsTLEkgWMuYRqZ8DkAlWQRaS71RyZOGyNXsgIfFbZZdL5JftF X-Received: by 2002:a65:4789:: with SMTP id e9mr21963912pgs.361.1643748716940; Tue, 01 Feb 2022 12:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643748716; cv=none; d=google.com; s=arc-20160816; b=wIQt//P9luJRl0MFjXTvTt+zPdz6u//nb5u5b3NOkY2+Klrh6An3lowYFHhJ73saOb N23ACgBSOQGozYrT56ctsbWLxN6VdlVK3cly8lfIC/pcbceD6ln3Xta5SSP6jI4Hdvkk XLFQOiKKCoeVOOd3vfIqS06kUxiFa3b2rp7u1u/Y3/rnx1qu9oDNqsdO5o8PiCGP4r9+ UZh4/8JigmTMEWRjW3wDaZa7aLWihYsQFmhucJDssrYWYTKqNksKfr1ww7RP199AZy2l zp7XoqmrfTsVm9BI7+QsbtAVrh17E0QF6LvR64VNtExIz4asDQqNiojRZO0A7psBHxrk 3msQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fY293kK68vvdcex/3vE1UuGsMyzMf3hMzbBW0CECXWo=; b=bYhZk2HmeiOsl1AbWUOdUNY+THMYgemYcgXZZAOykB3qSZVdOQzBHGwxy0rzlZaxz/ 3D7uvF1y/m0VuV7Z9AxTASgJzxBBPl6ajeul3AOlR2FSPPM5HqWjPemCoq/mvXAH9yCx jA3DQY0GEyzzrKtO84PMDOa69vBjVVb9yQwN8uMxiFiucAKU1tY/kXOyGljsvvox8sj1 WXLLujdnH0YnAO/6YjF3fuIDmCf955lFfKIstFuBwtapdzqplqlXU0jfPGJ4X6NE7rQ8 VfW0L6F6rnvvbarhEaKgPE8JSmjwbEz6ZJ33L9iFOFnNw6Py4lApE7aNMPshUq2S4cb0 xTzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=sbuqsKlK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si17072825pgl.624.2022.02.01.12.51.43; Tue, 01 Feb 2022 12:51:56 -0800 (PST) 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=@google.com header.s=20210112 header.b=sbuqsKlK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359216AbiAaVeu (ORCPT + 99 others); Mon, 31 Jan 2022 16:34:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241365AbiAaVes (ORCPT ); Mon, 31 Jan 2022 16:34:48 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EA20C06173B for ; Mon, 31 Jan 2022 13:34:48 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id p27so29706598lfa.1 for ; Mon, 31 Jan 2022 13:34:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fY293kK68vvdcex/3vE1UuGsMyzMf3hMzbBW0CECXWo=; b=sbuqsKlKtbosk9vnW8XyVA7uztBNuHZfZtcNYRiovUgAycS22JZkJ7MxOjZiMGYokE xhXCNkbCRNT88OXvTMndIJGfh2RMckU46x0hrSqGUrxA1AJFOX8bMhXN3oqNP8+elCU0 lvDAlF8N3I1u2nhtJaNaqw50gxUEox/7eGGrd2H8M1MqUxiEK4xBNMrtaG72GFm6gQLD qpV2iT3ZgC3M5XpLy/d3zAQeGz90PRYlxIDLCQX2VGb4CyN+fEuNTon7uZ+TdCW3h+Lm bOazphReVxD2+MfnXlHtsZydG2omK43C943jxFBmLXKyDFoYPGqR1UCZxsGliywnVtxc xU9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fY293kK68vvdcex/3vE1UuGsMyzMf3hMzbBW0CECXWo=; b=hcO2HT7WPiRQmIOdQlK0eCxzzhW6LzPBO3wQ/m4GGYjf46IhAlKAQnVSNqanZE7izr 8r5RWVQkdA0+vpXgmDQ4mlQhM5a6kKkCqzaqByCuzX15UIX/nW/rdGhfNzI/98ZSqdfD 9HLVPQBm5ziE46Ark9g1zTJEClIfcPbnJ6f2KDZeufwMoO2/ND8Dw4N8MlhRwNksOrlN Oa7q3u8AtLpfMFP1h7WCOp8wWtyTX91whBnCp5/VTiAyKu++TPOukzNkQd+qdDK1plqp 3KXeqksBd0wBNXqiN/K44lgu+PFOZax8/n8HUh9McuQsstNnNkaaJwnlkJmE79xxqqYD rW/w== X-Gm-Message-State: AOAM533TbnughG0wuuVyjcWxRkgtcMnhxKOHxiqSv0wTyunPXwupVNi/ Oar8fTUpkuEh8csM8HutQv+XWqoAdN7XrSVC/E04mg== X-Received: by 2002:ac2:4e10:: with SMTP id e16mr17500223lfr.444.1643664886497; Mon, 31 Jan 2022 13:34:46 -0800 (PST) MIME-Version: 1.0 References: <20220130181616.420092-1-keescook@chromium.org> <202201311306.0FC6E303@keescook> In-Reply-To: <202201311306.0FC6E303@keescook> From: Nick Desaulniers Date: Mon, 31 Jan 2022 13:34:34 -0800 Message-ID: Subject: Re: [PATCH] fortify: Update compile-time tests for Clang 14 To: Kees Cook Cc: Nathan Chancellor , linux-hardening@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 31, 2022 at 1:09 PM Kees Cook wrote: > > On Mon, Jan 31, 2022 at 11:09:27AM -0800, Nick Desaulniers wrote: > > On Sun, Jan 30, 2022 at 10:16 AM Kees Cook wrote: > > > > > > Clang 14 introduces support for compiletime_assert(). Update the > > > compile-time warning regex to catch Clang's variant of the warning text > > > in preparation for Clang supporting CONFIG_FORTIFY_SOURCE. > > > > https://twitter.com/ifosteve/status/1190348262500421634?lang=en > > error messages can change over time. More thoughts below. > > Sure, but I don't want the compile-time checks to silently regress, > which requires looking specifically for the error. > > > > Cc: Nathan Chancellor > > > Cc: Nick Desaulniers > > > Cc: linux-hardening@vger.kernel.org > > > Cc: llvm@lists.linux.dev > > > Signed-off-by: Kees Cook > > > --- > > > I'm splitting this patch out of the main Clang FORTIFY enabling patch. > > > --- > > > scripts/test_fortify.sh | 8 ++++++-- > > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > > > diff --git a/scripts/test_fortify.sh b/scripts/test_fortify.sh > > > index a4da365508f0..c2688ab8281d 100644 > > > --- a/scripts/test_fortify.sh > > > +++ b/scripts/test_fortify.sh > > > @@ -46,8 +46,12 @@ if "$@" -Werror -c "$IN" -o "$OUT".o 2> "$TMP" ; then > > > status="warning: unsafe ${FUNC}() usage lacked '$WANT' symbol in $IN" > > > fi > > > else > > > - # If the build failed, check for the warning in the stderr (gcc). > > > - if ! grep -q -m1 "error: call to .\b${WANT}\b." "$TMP" ; then > > > + # If the build failed, check for the warning in the stderr. > > > + # GCC: > > > + # ./include/linux/fortify-string.h:316:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] > > > + # Clang 14: > > > + # ./include/linux/fortify-string.h:316:4: error: call to __write_overflow_field declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning] > > > + if ! grep -Eq -m1 "error: call to .?\b${WANT}\b.?" "$TMP" ; then > > > > Doesn't this depend on -Werror being set? I guess it did so before > > hand, too, but couldn't I unset CONFIG_WERROR then this check would > > still fail (since instead of `error:` we'd have `warning:`)? If we > > used __attribute__((error(""))) then this would always be an error. > > Right now, it is only because -Werror is set promoting the warning > > diagnostic to an error. > > Right, see earlier up in the script. "-Werror" is explicitly set: > > line 40: if "$@" -Werror -c "$IN" -o "$OUT".o 2> "$TMP" ; then Yep, I missed that. Reviewed-by: Nick Desaulniers > > -- > Kees Cook -- Thanks, ~Nick Desaulniers