Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1407608pxb; Fri, 22 Jan 2021 15:18:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/A86iF1HWX9r92aDFQEKFUD79GcDfFb2wXcnkTAXNe6joX/CTBf2koRg83gu5GNET5xsC X-Received: by 2002:a17:906:dbf2:: with SMTP id yd18mr4404148ejb.45.1611357510666; Fri, 22 Jan 2021 15:18:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611357510; cv=none; d=google.com; s=arc-20160816; b=roSh2D3qkBUQ2ijkQlG0CA/v63YMDHRwdgExzSqiIum5tAHnHSbkBov9FcGmCeXIWY D+/EacI7Q/dDYkencrdwEZRQ5Ri9fenJgzxj/6Yjv747ZWzDa8U/E554ERx9SrZmNAhN qbFjnFsOCGk3dN/Z4zLPbVCOTIWVFiqM/szYWNQq8XtIx4JsRds18BaQ0L/VVgQU0i0M a3/JFJv8RBDMra5WMUBJniVAOMPEOiM5HCMpJVrgYhVplaL4YDm/wu5bBh7QRn2P1cNa UcAhn/cODoG5OaHjBClz+sWxp6/1Knz/YVXne2bKyDTtMuqax/Eft5ifc93X9/m75B71 1zNA== 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=PRHYirbpaVjReacEED4lbaCE3EfoPDnBMgBWDqUdb1M=; b=fJ0YSCSrCjOcXi8R+pQp/jSU3R3dtlvM/mghNPmXYNQi5EQcsZWi1sdKj4XR48OfbB 5Zp/R09yXkmblrDwIrh6/kUegqmFNL9TzT3KUl33zWXRvdV92BIoH7v8N1O2l+ihVcIB OFSv0RUzH+cBYk9k7saBBiwBFSmavdjqEJjB2HMBibo6GsL+rVcIrWgHB2ExqBtOBMps m1kc2Qwc68tDcjszIlc51KIp+dIMJyU7qUnqB1iLdnio3TmcAOM6JfiZKTbX1RLl2aNM XE3hhDWRDZ1NL+zkzUcrWOY87z71CW9piLu+7GfCS6TEtbXySB9hMcfGWmSJ3B15zkv5 ASxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jcbK3Jb+; 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 a4si4126490eds.606.2021.01.22.15.18.07; Fri, 22 Jan 2021 15:18: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=@chromium.org header.s=google header.b=jcbK3Jb+; 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 S1728892AbhAVXRR (ORCPT + 99 others); Fri, 22 Jan 2021 18:17:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728480AbhAVTfF (ORCPT ); Fri, 22 Jan 2021 14:35:05 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DFE2C06174A for ; Fri, 22 Jan 2021 11:33:44 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id g15so4472450pgu.9 for ; Fri, 22 Jan 2021 11:33:44 -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=PRHYirbpaVjReacEED4lbaCE3EfoPDnBMgBWDqUdb1M=; b=jcbK3Jb+1ldTw8xuHGcbe/WyAd9rzEWhNsbjwzL7GUFNO0kBbs7g9+lznqTJXv5guQ ThmJrhp8cBtmrAw3PicbPDCzSDRMsMTXouV2Ed/Soxu0Aianbna8t6Eyn8vx3xOUitbj /UrYMZXa4Z2WVDt0h6nszyYChGEcP/Gw8IFgQ= 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=PRHYirbpaVjReacEED4lbaCE3EfoPDnBMgBWDqUdb1M=; b=cDzNOT84PcwIEJmnWuthvGEcBOKt76T8rPmxxqF1EnbD7ZCCfXBfISxjx5ggDcQA/1 p2LtudsqiSncbTa0IuT6c4cA+i/LZbX1SnP3Bgxfxy0GQWJbDoVt+Tkgj2KSUKb3UkRB vcvejSdNLMxLIeTFQm6lK0eoktmtqcMPwWTocTJ9/j2pgGoOuD2NXd729rjiyAyskD4D cx8Y27QbzQzqJuixUBj2gBChAXHq6MqIROQ+EeThBfB23WGZ+vnrJgAkZrG9qJG6Nuqu ivx3rDTqUaCBpdgaKJ5J2l+TN4j9if/rhWsGSDLi/cS8MhkGeBUlDWRXCwYPKk9D212B fGjw== X-Gm-Message-State: AOAM531l+Wty3PIoQ88vnt+4xCIHBH7NU4Bc0JNV9XVCRhXa298n/bIn M+OkInpwP54n5fX0JSUf/OH56Q== X-Received: by 2002:a63:1e1e:: with SMTP id e30mr1322451pge.156.1611344023652; Fri, 22 Jan 2021 11:33:43 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 129sm9463735pfw.86.2021.01.22.11.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 11:33:42 -0800 (PST) Date: Fri, 22 Jan 2021 11:33:41 -0800 From: Kees Cook To: Alexander Lobakin Cc: Sami Tolvanen , Masahiro Yamada , Michal Marek , kernel-hardening@lists.openwall.com, linux-hardening@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH kspp-next] kbuild: prevent CC_FLAGS_LTO self-bloating on recursive rebuilds Message-ID: <202101221133.389539337D@keescook> References: <20210121184544.659998-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210121184544.659998-1-alobakin@pm.me> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 06:45:55PM +0000, Alexander Lobakin wrote: > CC_FLAGS_LTO gets initialized only via +=, never with := or =. > When building with CONFIG_TRIM_UNUSED_KSYMS, Kbuild may perform > several kernel rebuilds to satisfy symbol dependencies. In this > case, value of CC_FLAGS_LTO is concatenated each time, which > triggers a full rebuild. > Initialize it with := to fix this. > > Fixes: dc5723b02e52 ("kbuild: add support for Clang LTO") > Signed-off-by: Alexander Lobakin Ah-ha, good catch; thanks! I'll get this into the tree. -Kees > --- > Makefile | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/Makefile b/Makefile > index 668909e7a460..2233951666f7 100644 > --- a/Makefile > +++ b/Makefile > @@ -895,10 +895,10 @@ endif > > ifdef CONFIG_LTO_CLANG > ifdef CONFIG_LTO_CLANG_THIN > -CC_FLAGS_LTO += -flto=thin -fsplit-lto-unit > +CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit > KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache > else > -CC_FLAGS_LTO += -flto > +CC_FLAGS_LTO := -flto > endif > CC_FLAGS_LTO += -fvisibility=hidden > > -- > 2.30.0 > > -- Kees Cook