Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4759329ybp; Mon, 7 Oct 2019 13:32:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxxR79cI5pWND4Qeq+GTTaVZBp5x8j68A7usPTf84QEoYq47F7p207lJxCjAlD9NaVqyRy X-Received: by 2002:aa7:dad3:: with SMTP id x19mr30948208eds.59.1570480361145; Mon, 07 Oct 2019 13:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570480361; cv=none; d=google.com; s=arc-20160816; b=p/fe241BSSNGgLuL+fvtNteZfvgQRsoCQEWEk0ZwzyFPD1Qzb5UecuB7pIW4hO7cHM nIK5HkC7ABf8ifpfWyQM973jsYM7qviS7hYdjfjLEFTFi0QlXeqLdrwS3DVW0UzCL3QO J4z8dLh2fIzNemBee/NxsIMshGKn6zrj0a6idio4T6pKQNSHT9MfROM3J5bvRADUNvUv jhdsuUepTGXKV8SD62p8x9GhHbcl9WKkotODwslLik/CYD4XRV/1OF7uGnDO4kBBC1/P py+fLPsibNVCaAO/YXo7jYcv5iyZif85BrAJSHdlhwjOzE97dmMfpHBVzlb2QdN7zmWp Sn3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ZahjNxBnWmuuim9IzUhby0wk2/Lj6XTRdRHJ5wVrf9E=; b=BqkH3blc3Ruqp/UQhIvmxqAq7ridgcP7UTIV4uOD6uhRNvaUugP8jIdLy6sBXGw6aG obTg0M6aeIQS8DdVqUa7thtXbkdobngV9znJV48RrV8RLeEN8gU67neSqHiOI+rAbGte 7tvCGhfvoTXjzzbjUtwS9Y8/feLv5/GLlwxHx3Wwp7ove3wtdJDV1k8Rrg9hBjTBATLF SL65TobZhQjJeb4MNoJO26F4/cS/EldJ8tqZmXPRVlF6GiiSiUDuRALF7UxcnMA2jJq+ nt197gqCANUjjQsflEmUXKta16D6HAGPk4Xpeq64cVOwWByTigH6zYjY8pnYPwVDNErg i4fA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si9515971edh.242.2019.10.07.13.32.17; Mon, 07 Oct 2019 13:32:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728567AbfJGUbx (ORCPT + 99 others); Mon, 7 Oct 2019 16:31:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47446 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728187AbfJGUbx (ORCPT ); Mon, 7 Oct 2019 16:31:53 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 94C227BDB6 for ; Mon, 7 Oct 2019 20:31:52 +0000 (UTC) Received: by mail-ed1-f69.google.com with SMTP id a21so3001087edt.19 for ; Mon, 07 Oct 2019 13:31:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ZahjNxBnWmuuim9IzUhby0wk2/Lj6XTRdRHJ5wVrf9E=; b=DsnzYvX7pPo2IEJGXZbxgdMmtl/m9u/iHxs/3SDavTacm0qvhyzRBrQWq7qPH1/xX4 u1Xd0BXQvHirxAildSfplCklZ3GWCWdqIkYyFtx9NeT4174ho1dohGLp5PaH3KluQnO8 neSoS2YSWa2pcrBDk03PU/URr6iZqeE0s1xF0+d0nrqEBaQufB+ioXnqmaPByrTnkn/5 Ht78oHRcQTfjjtCy18CbOs7pLKzGpEuuNLi7ZfVVuvhKSHLwXrprqaTBWm+rD2CR7g8c mS538R3o0wxtVaVBVTbIJLFi42RAbodRVKQlc2XF0k4OBmlBPIWkj7NcHvfPkpd7RDDc m9AQ== X-Gm-Message-State: APjAAAWsVQjWlABbwmEcSUtAhSOgAR6XJwVL4+EIroSArK7KcXtT20SJ DyBvgUwZ4Jn033kMe5yrG/arTZFpdt4DMd4SsMf6u55dOAKvYuaX7oMj6nbMxxfQirIBjSfY5cq IXC+W2RlTDmleIWxdS1YnkMYE X-Received: by 2002:aa7:cf86:: with SMTP id z6mr29916231edx.230.1570480311308; Mon, 07 Oct 2019 13:31:51 -0700 (PDT) X-Received: by 2002:aa7:cf86:: with SMTP id z6mr29916216edx.230.1570480311090; Mon, 07 Oct 2019 13:31:51 -0700 (PDT) Received: from shalem.localdomain (2001-1c00-0c14-2800-ec23-a060-24d5-2453.cable.dynamic.v6.ziggo.nl. [2001:1c00:c14:2800:ec23:a060:24d5:2453]) by smtp.gmail.com with ESMTPSA id e52sm3525184eda.36.2019.10.07.13.31.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Oct 2019 13:31:50 -0700 (PDT) Subject: Re: [PATCH] x86/purgatory: Make sure we fail the build if purgatory.ro has missing symbols To: Nathan Chancellor Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Arvind Sankar , x86@kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com References: <20191007175546.3395-1-hdegoede@redhat.com> <20191007200529.GA716619@archlinux-threadripper> From: Hans de Goede Message-ID: Date: Mon, 7 Oct 2019 22:31:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191007200529.GA716619@archlinux-threadripper> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HI, On 07-10-2019 22:05, Nathan Chancellor wrote: > On Mon, Oct 07, 2019 at 07:55:46PM +0200, Hans de Goede wrote: >> Since we link purgatory.ro with -r aka we enable "incremental linking" >> no checks for unresolved symbols is done while linking purgatory.ro. >> >> Changes to the sha256 code has caused the purgatory in 5.4-rc1 to have >> a missing symbol on memzero_explicit, yet things still happily build. >> >> This commit adds an extra check for unresolved symbols by calling ld >> without -r before running bin2c to generate kexec-purgatory.c. >> >> This causes a build of 5.4-rc1 with this patch added to fail as it should: >> >> CHK arch/x86/purgatory/purgatory.ro >> ld: arch/x86/purgatory/purgatory.ro: in function `sha256_transform': >> sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit' >> make[2]: *** [arch/x86/purgatory/Makefile:72: >> arch/x86/purgatory/kexec-purgatory.c] Error 1 >> make[1]: *** [scripts/Makefile.build:509: arch/x86/purgatory] Error 2 >> make: *** [Makefile:1650: arch/x86] Error 2 >> >> This will help us catch missing symbols in the purgatory sooner. >> >> Note this commit also removes --no-undefined from LDFLAGS_purgatory.ro >> as that has no effect. >> >> Signed-off-by: Hans de Goede >> --- >> arch/x86/purgatory/Makefile | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile >> index fb4ee5444379..0da0794ef1f0 100644 >> --- a/arch/x86/purgatory/Makefile >> +++ b/arch/x86/purgatory/Makefile >> @@ -14,7 +14,7 @@ $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE >> >> CFLAGS_sha256.o := -D__DISABLE_EXPORTS >> >> -LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib >> +LDFLAGS_purgatory.ro := -e purgatory_start -r -nostdlib -z nodefaultlib >> targets += purgatory.ro >> >> KASAN_SANITIZE := n >> @@ -60,10 +60,16 @@ $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE >> >> targets += kexec-purgatory.c >> >> +# Since we link purgatory.ro with -r unresolved symbols are not checked, >> +# so we check this before generating kexec-purgatory.c instead >> +quiet_cmd_check_purgatory = CHK $< >> + cmd_check_purgatory = ld -e purgatory_start $< > > I think this should be $(LD) -e ... so that using a cross compile prefix > (like x86_64-linux-) or an alternative linker like ld.lld works properly. Good point, also the ld command is actually outputting an a.out file which is also something which we do not want. I will prepare a new version fixing both. Regards, Hans