Received: by 2002:a19:ef0c:0:0:0:0:0 with SMTP id n12csp950192lfh; Tue, 1 Feb 2022 12:51:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxi0VYKikk3ObaATuYu44nacxKekqBs+z4iUFts0REuPmqH/vORX4qQEvnOysappekIfAKN X-Received: by 2002:a05:6a00:23ce:: with SMTP id g14mr26687697pfc.13.1643748623623; Tue, 01 Feb 2022 12:50:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643748623; cv=none; d=google.com; s=arc-20160816; b=nBwyeZVyFwIKekzocFxLR9Ixs5sfyFVk6SvsbF6Ub8Y9eVMy0WGmUBk2LvL94meKsO NN5Mylj/X/3GhQAs4WTQpPzdoJRPKu1S2gmRjhcffUN2tVwucdyVzjw8lrkk8MwObVUv wUcfd6tb26XB73sUKWq0Y+5xbzj23JQzSrdVr0z3IFlkSObc8jsSG3i4rUdTe/NiiszU u0ocbV8U+7rCrNT4/abCob+OEtgux67ahdFRSKNoOp/1OEzAzJV2bhn2K/G7oKaj+TDY qxTmtiWofbM1wkjTJCigL530rc+CWMWLUyctt6YDVGnyFJPID36mJ/+l6AsRob/ip0fg QRhA== 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=QkhfbO5ZuAnM+4vhyHXHVmq11kG0AqyRd/tsjcMAl14=; b=q0DuQJMsKCiQuUeq2qaIdQWTJkgSW8R3jWVEOZHDp8Rh6KACdrgyNnb2G85tmGRZeq JE93vklymszaSvWqwDPgap87bymM1lTssj86x5BuFRBcS2y4hcohOZS9Ley4eoe2M67f hixa5A5cBlFZ9DpZGrdJLoFoQolKm9QgUi9o69wyKeX2gTyX9BJqduJ91iAC7pwBF7zW +x9F3bap1yHGhHPjLSsnm7Q+7a/kJEbibHusbQHkyRVRItSWhuBZ6OMpcsEXT4N+GAwl FeVwdzk31ij+Z9suPu7jCxUhNBpU47LzyxXaOcNPRITk/BGvGQkf/xBRrVJ925bfvBvW bnzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="F/nlSE/y"; 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 oc17si4027995pjb.13.2022.02.01.12.50.12; Tue, 01 Feb 2022 12:50:23 -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=@chromium.org header.s=google header.b="F/nlSE/y"; 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 S1379721AbiAaVKK (ORCPT + 99 others); Mon, 31 Jan 2022 16:10:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380007AbiAaVJm (ORCPT ); Mon, 31 Jan 2022 16:09:42 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86057C061401 for ; Mon, 31 Jan 2022 13:09:42 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id 133so13431618pgb.0 for ; Mon, 31 Jan 2022 13:09:42 -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=QkhfbO5ZuAnM+4vhyHXHVmq11kG0AqyRd/tsjcMAl14=; b=F/nlSE/yNJSASXLMWSaLGYR1yLL+hmZl/FP19SuvRwCudcOLOFjyjyVSys+cJHT9bd DiZvJM5FOigFZ+06vJkHc2u3C3fnV1/DSbQTDMK18auGH7E+/aYpx456r1n6VPV2cenW 5C7lLsPmpGYiN/CdnhIbAxw1RAA+Yh655yk9o= 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=QkhfbO5ZuAnM+4vhyHXHVmq11kG0AqyRd/tsjcMAl14=; b=d4CV987G2kaFuL860QncG1L2QQHCp6euUPZvLvaGESJOYqs+jig7oswP5dUMAOjpuK 4Vq2dR5oP0RSEQVPmqWZFSQE1xIB+58Jo3sNXfO6u5mywGq9Ju4hiq4ruXSPYcREwHc1 31qerwKluwj5ij3DtzvsEqlEa4cy7fI5/ahrzxzPuM2EZRzUuzfJOB/CZVCWx5r7zpyT SNRmte09V/xHSoUtdaM/+yn4Kb3AKATx0e1NPs0VX1qdi6LliX72cePzXnDIHs8OcVWO fEiayBWCyIk6fF2wbe+D1CV+f0B14zPbR9byos0WgyQFZz0kf3VXzEAQDgFfzqI5v8pz 9wsg== X-Gm-Message-State: AOAM533Bzc1H9wanyYLo29ifk7ySaHJqqdrN0bM52EZVZ8TWjzWnZ72m GbfnUp87yF3FkqERnUpso7vmOw== X-Received: by 2002:a62:1dcc:: with SMTP id d195mr22080045pfd.4.1643663382057; Mon, 31 Jan 2022 13:09:42 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id bj7sm228915pjb.9.2022.01.31.13.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:09:41 -0800 (PST) Date: Mon, 31 Jan 2022 13:09:41 -0800 From: Kees Cook To: Nick Desaulniers Cc: Nathan Chancellor , linux-hardening@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fortify: Update compile-time tests for Clang 14 Message-ID: <202201311306.0FC6E303@keescook> References: <20220130181616.420092-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- Kees Cook