Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1478496ybb; Thu, 2 Apr 2020 01:20:20 -0700 (PDT) X-Google-Smtp-Source: APiQypLcgOSg6JuXI9KnYV2Ca8x+DnfAjuOgqRDzfO1OfyYuy0kIZTzWAahkubgxgKw8NMp6DFoL X-Received: by 2002:a9d:8e4:: with SMTP id 91mr1570392otf.130.1585815620834; Thu, 02 Apr 2020 01:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585815620; cv=none; d=google.com; s=arc-20160816; b=HiW2Vr2c3mdZnodYqwV1ntR1uPOrD5r9C4x+1PlKS9kXPTcJgy0I+lappooZLczn+b pHnCXe2eniJsJD12K/hcQL3C7On4+fXrbMsFoCUg5E9VKp6vP+PTvv6JG0SiwFM5EgLE BMXv5FFyc38w23pFGifkTGgoqiiMwjchavqQn8wZAXqcRklgU3ydGuq+f6gpALVzgen7 YB740Tu8/5ezmWWxCa9i9HYfxV/Jc8Wn/+Ml3a9woxNP3YcFpRKsX9nSEbWuEegYGsyV juphu9vb5cEh1e+Kpa83SJpKdbnoesyOrD++FOjKov/GAMvUaRBJ9vvSC7BliRvsCelo Gvpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=hpN1+n5xYd8iTmuJk5my6MaX1tvwBISzriW+LumWFUk=; b=YXW8SxhwWiz1aAnnKEdE4z4i7XBCKbJNotiHyfGYx7y7RZU/fIG05rjaXvL4R8w1d5 7a5fE5SdQ/TNyyLb2vXWVyvOdN1pEqIAtv3uPVRwasHEl73wyAoNi0kP3QtAiOigIV2S oybqAnek6Cf0R1YAFOlS/bGbIFcbdytYTGB85Ps8XEPAiphrkb2JJCZnBMZOlZMtDndG QcUWYNwOsBAGyjxMtiH8+C5ZDnc+nG7t4d20sk3ULWqpsmd284P3iAQt/Ape6qjZLB+4 g5Se72/wHH44y3qI/utXC6Dcj57CLiAHEIANrS14uSNzLNGOuHYE2abCD7NOJMJoL0yC sefg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ShO3r9RV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id o63si2156300oih.74.2020.04.02.01.20.09; Thu, 02 Apr 2020 01:20:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ShO3r9RV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2387700AbgDBISl (ORCPT + 99 others); Thu, 2 Apr 2020 04:18:41 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45752 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387673AbgDBISk (ORCPT ); Thu, 2 Apr 2020 04:18:40 -0400 Received: by mail-pf1-f193.google.com with SMTP id r14so1390537pfl.12 for ; Thu, 02 Apr 2020 01:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=hpN1+n5xYd8iTmuJk5my6MaX1tvwBISzriW+LumWFUk=; b=ShO3r9RVFJZ69eJ6byI7q2iz1t91raVXjWEe0QObFryEOAOkMf+jsr93cWzT2A07ay tOt9WfOyads4m3eR2gKxGs+lp/CkGNsVymK8DVt+GBfZkqswyJCJEMSLyklId+ltw9bg /SMxHpXFUrXKGVqyyDgp6/5QGvCoFedfuQIhg= 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:mime-version :content-disposition; bh=hpN1+n5xYd8iTmuJk5my6MaX1tvwBISzriW+LumWFUk=; b=U8Y9tfACjXiTfWgWRpqFpzGJFTn/lNm3x+a+gZNM3UPBjAS0eHzPLJPwpr64nvMkze 9SGY5JL1oFa0vYJpLw8jDFM1aGzjgh7JgPgGeCZRwoaxlHtxtfjo85q41qfhxbxVK2Br PZFr6ryiXIDOCGzNEGzur+lt2VtyCNofkITczMAxUX+v4ievxjV8aaHR3ByThFutkpDW 1CAIeSaD5HIw1S9d+uIaM8Hdd6atulT0TE+g1GiVSzbuCLu2nU7AcGd+OHPNvtzt3aDi pq1G0pff3GRdaytiAhFratxfzOLna6DsLw2CN8q7Xg53nD1rD6pJ74jAFRXUACt0GCGv tbxg== X-Gm-Message-State: AGi0PuYboF43T72EDqBjDJ46uAabukQwp4gfOIq/GHluQF8CQbbIZTzQ cIuO4abOXc8/k8XpoiAe2fUpzw== X-Received: by 2002:a62:64d5:: with SMTP id y204mr1940179pfb.227.1585815519516; Thu, 02 Apr 2020 01:18:39 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l9sm1340387pff.16.2020.04.02.01.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 01:18:38 -0700 (PDT) Date: Thu, 2 Apr 2020 01:18:37 -0700 From: Kees Cook To: Masahiro Yamada Cc: Michal Marek , Thomas Gleixner , linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: mkcompile_h: Include $LD version in /proc/version Message-ID: <202004020117.6E434C035@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When doing Clang builds of the kernel, it is possible to link with either ld.bfd (binutils) or ld.lld (LLVM), but it is not possible to discover this from a running kernel. Add the "$LD -v" output to /proc/version. Signed-off-by: Kees Cook --- init/Makefile | 2 +- scripts/mkcompile_h | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/init/Makefile b/init/Makefile index 6246a06364d0..82c15bdb42d7 100644 --- a/init/Makefile +++ b/init/Makefile @@ -35,4 +35,4 @@ include/generated/compile.h: FORCE @$($(quiet)chk_compile.h) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" \ - "$(CONFIG_PREEMPT_RT)" "$(CC) $(KBUILD_CFLAGS)" + "$(CONFIG_PREEMPT_RT)" "$(LD)" "$(CC) $(KBUILD_CFLAGS)" diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index 3a5a4b210c86..f98c07709370 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -6,7 +6,8 @@ ARCH=$2 SMP=$3 PREEMPT=$4 PREEMPT_RT=$5 -CC=$6 +LD=$6 +CC=$7 vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; } @@ -72,7 +73,10 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)" printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY" echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\" - echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\" + CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//') + LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \ + | sed 's/[[:space:]]*$//') + printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION" } > .tmpcompile # Only replace the real compile.h if the new one is different, -- 2.20.1 -- Kees Cook