Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4606447ybp; Mon, 7 Oct 2019 10:56:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQ1xRx3Iva7AOEQ0iwCqrZOltPvLBTiWiZF9I7P9ecNSI2LSwj16hAtV86IvrJ4rKZBpfe X-Received: by 2002:aa7:c5c2:: with SMTP id h2mr30772851eds.260.1570471004431; Mon, 07 Oct 2019 10:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570471004; cv=none; d=google.com; s=arc-20160816; b=FhUb1TOGrYS8S6kXR1Rh/JkN/VNmqFg2GadugajaGzp/sTLbO/AI/rKhLyoMVPx5OL NcFrIp8hYT3XLL497VjZtyHlD4G326p2jAj6XLyQv66SA4Oqd7xhH0xmydQtYgCFOK1q DDeGRE4ZHUomYpoQcCu16HIgYvsp5+ip4E5lmAmxkFM86oB6etVTjwco5m36p7E2vx6S 0pbcQ/HsA8Nck3P5xgMaQKrKAK7vSj97O+be+/5UOm/8DKtl4y318KFD/KCqpuC/asIy l+InTRmAW/pUjii6NwemVK5UFg/7J6RK++iJT25xBuf+fX+5yYsaa7n+ON4mVFuFCv5U uomw== 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:mime-version :message-id:date:subject:cc:to:from; bh=7l2KO6wuigFz8eyt4N2tpfqtJpAE9NDXzPdCnp0SITo=; b=mOkZsqY2YGUs4wSbRMolSXf1cLrDTu6v9nuJEbdYvkPAVjJvnkq8uZmKUtJJw2PY8P EC2ZBMgGPxqVql8wQW7U/sp3gyr7u1Nsoa2JrDAiIJMkjeaShiVEHYOXiXJfnXxXJxOK g++yP/T+2Ag2kWPEjW7R5SoI+MGzk9qlfukm2PNNokJOawearkQurJ2+Bsq3vZN5tuc3 z3KgUW5LZcylG/oWk6ysnikXL6F2KUtIJwqplNwghHHZaV+t3oEThxd1FPaLXn3oJXE1 ZidJCXpqlkWeZOzwSbDJGS/sGLidJ0NDWrtARgY1dZXhz3KCzvYiIOBGrW2y3bgwoFdG IsOA== 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 m5si6240755ejr.417.2019.10.07.10.56.20; Mon, 07 Oct 2019 10:56:44 -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 S1729342AbfJGRzu (ORCPT + 99 others); Mon, 7 Oct 2019 13:55:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50842 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728079AbfJGRzt (ORCPT ); Mon, 7 Oct 2019 13:55:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 417847F745; Mon, 7 Oct 2019 17:55:49 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id A03D660606; Mon, 7 Oct 2019 17:55:47 +0000 (UTC) From: Hans de Goede To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Hans de Goede , Arvind Sankar , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86/purgatory: Make sure we fail the build if purgatory.ro has missing symbols Date: Mon, 7 Oct 2019 19:55:46 +0200 Message-Id: <20191007175546.3395-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Mon, 07 Oct 2019 17:55:49 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 $< + quiet_cmd_bin2c = BIN2C $@ cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@ $(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE + $(call if_changed,check_purgatory) $(call if_changed,bin2c) obj-$(CONFIG_KEXEC_FILE) += kexec-purgatory.o -- 2.23.0