Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp903022pxb; Tue, 1 Feb 2022 12:49:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIqD8I0PFFsWKmT+uh8sblkzmAGQQ21sum4aqmjQt0DypQkdbdCT8gKQlLqx+ZlBJ6yK1U X-Received: by 2002:a62:e219:: with SMTP id a25mr14030887pfi.62.1643748570802; Tue, 01 Feb 2022 12:49:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643748570; cv=none; d=google.com; s=arc-20160816; b=Hc5MKRlJbP6wJWVlxPfNrQGmlQt+yinHm0t41SUxTuoKORKfgZGl79vTNLGQn+RJcD rtk98cqYpH2tJHivVgHnqdRxRFq9HpRB/XuJDUxaZ8+TvpCntO5FK3/IQ6lgEj7CTAcA ylqi9i+3S5gUWfypp8MKMSKLLc7gH8YxFOvkvcuSXqZLa1KbKDpAQ9SXXRScVUj9cTsr 7JLj7sB2v7EBEqyXYnpSQ5mVhYCeYrcUxn7PoARvDGAuAXeYM2DVTyyqiju5ljaEaJTa h0QH8x2nB5dP1F4yowg9uDGT0Rn4vfc/lvcNRoGS3ARxdmvmu+286YGbD3Z30eFeamtD Ejyw== 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=3Ok0BFBVUs/aGLvZ8hIj39mJA1z2SbFZGpjd3f3p7Vg=; b=CEaV9zjz3/GnChxsvB4cRyAuCmoquSDbFH4rsgmg5iyAPDBx+YRMgvVLLTGdoI26fp u/8XZOZqHbibcdxREDVF8cqQIF+n3ud08kF+1zJGUQQ6YqWW3k95nrIp1zg9TMAGMGXc L3ggp1FtKp1hh7Uix3r4HTCl5PFYhfV3UpHVDbSx618voWEsr14/PQuJZ+3E72nDXAV+ 8XqIPXh9QCP3jjxKEn9TZ9wVgSzzQMHZ38sY5qKqaAB4mkAguJoFTpYUk/p2PPRPNzXU t8BzqxkWsSwGPTmiFZ97h21osFW2C56eZYN8VIBtJ0xsHfIzUvUD/X9MEP1mQfDL86FW Vgog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hX0xetF3; 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 12si17557806pga.691.2022.02.01.12.49.19; Tue, 01 Feb 2022 12:49:30 -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=hX0xetF3; 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 S1359132AbiAaTJr (ORCPT + 99 others); Mon, 31 Jan 2022 14:09:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235245AbiAaTJl (ORCPT ); Mon, 31 Jan 2022 14:09:41 -0500 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15298C06173B for ; Mon, 31 Jan 2022 11:09:41 -0800 (PST) Received: by mail-lj1-x230.google.com with SMTP id q22so20798426ljh.7 for ; Mon, 31 Jan 2022 11:09:40 -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=3Ok0BFBVUs/aGLvZ8hIj39mJA1z2SbFZGpjd3f3p7Vg=; b=hX0xetF3Nl2xlWjDIF6C04FvfYjWAUNtF9/XaoMWge4H3R+tddXnppQBiNsE0QcTf2 H1VLpE42C+1XDt+SPkmPcrXc+e5QUUVrzLLDhqapMhQ0cidbmLUZZ/2vX3Wacu7dyBxV Lh8kF3a4RuCGstgCCYTqIB+JyzvN46ciBhUsVNy/FS8vcwjWfECmOJNm+wgYUCFefL1M XUAeYfLXSWd6OTzBH/X9ZmXihVo+k4wq0R9j+D7BO9kOyjrCttYyR+72q4YPJbkP9z5o fWAhJ2aD/U2rBALByHUFY/TdI3p24zf2WUC2OpgmsXuJaqrlVpDqUy/pQvlF7nYYsZWG vbQg== 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=3Ok0BFBVUs/aGLvZ8hIj39mJA1z2SbFZGpjd3f3p7Vg=; b=qdfjoumSPocfG/zDi5O+yQDSO4/qDR2xoLhVVA5dSu6P3IyMJhUJVEFLph6HJz+oZS zLFpGCYbiRS1l70yorON5PzXjwribIWnuNeW24pppq8Qx/g2RlKx8kkwzZ34oVPZ4QZN 1g1iZMbq7CQHqI5A2jpPnCl+0eKdZtPpvqOj7inrJdMrG0soFhlglb1AdKb9AVBRN0Xb LQVmhLQcoPGVDajDGjRGhELitxPEbnOJ4icYoDUEfn7eSwJVmwhRwchqiBwDQ7mSkDc4 BfPNTnrs5F8RJVSELE9G+RlxbGSdhgsLS3w5P0GVLFzKrNWGtnyhCA7URkNBoupBMi5g eJ6Q== X-Gm-Message-State: AOAM533zbVZ/KwAu964ijDumXedfJH8JorZnTqYJDLKm/k8wlkxOZk5/ No2poLN+6pLCVDYpZhiMrWL7LAtUz8A++OrRh3sKDA== X-Received: by 2002:a05:651c:1253:: with SMTP id h19mr5956839ljh.338.1643656179244; Mon, 31 Jan 2022 11:09:39 -0800 (PST) MIME-Version: 1.0 References: <20220130181616.420092-1-keescook@chromium.org> In-Reply-To: <20220130181616.420092-1-keescook@chromium.org> From: Nick Desaulniers Date: Mon, 31 Jan 2022 11:09:27 -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 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. > > 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. > status="warning: unsafe ${FUNC}() usage lacked '$WANT' warning in $IN" > fi > fi > -- > 2.30.2 > -- Thanks, ~Nick Desaulniers