From patchwork Thu Nov 12 18:38:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11901045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E55BC2D0E4 for ; Thu, 12 Nov 2020 18:43:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC5D222227 for ; Thu, 12 Nov 2020 18:43:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LdSWY5DG"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="myShStDY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC5D222227 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=QgV/x1sbzRusP24gSsUewM2vzlc8CXjTv3xSYwxDiTY=; b=LdSWY5DGZPvb02DF3iCQua/x1G ttrZXSsRPkv1zjRCmNLRyaBrroyOPoFaXRsMKUpweNPl6tXt6HsoHCjJmk4BgSKAHzjaCYryEh4ay UL8NdCu9jCUTHhEmvxaw36gsndJb7Y7fn5E+OGu+H8QaCxRcP5sZqM0ZMKCe3I9dOm4RxtsK/8YKV nNWkCUj2tzZxSPyyWbYExWuuKoBzjifts8kGNSeZqTqz72i5cMJZ1mpfgfoXq2y6mAuaiWk4T58Pk X5LPkKJNVWC/BfTPP5sdNd5G+bM6+THJR5Ao9ZncjkxQu8j9QeGyMyaBpMLFG3/b4FQuY2/opoi52 rMztr13A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdHXX-0001Ow-KC; Thu, 12 Nov 2020 18:41:47 +0000 Received: from mail-qv1-xf42.google.com ([2607:f8b0:4864:20::f42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdHXU-0001Ny-Qc for linux-arm-kernel@lists.infradead.org; Thu, 12 Nov 2020 18:41:45 +0000 Received: by mail-qv1-xf42.google.com with SMTP id a15so1113220qvk.5 for ; Thu, 12 Nov 2020 10:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RbwUCO9/Da3fkPFh1nSPQACB3eAOSELwsDKteGbFH3E=; b=myShStDYB2xgfHPQDqhUB8MFR/KTGdBAv1Kmmq5w82QO2mVKDvfJvgc8ym1D802pCZ /VX2iMAYNOrb+NsUP/jCSqCN+kLWfLDRGj9KoS3QKs8HUmhdBPv9MFtOCkcAw4cBT27M 0yDWYlYkSwM9/fFLsOdUX4Qbx1n2qEtjLlnEouY0HHmjfGzwMeYkBl3r4oeJgDyW6pjJ Fa1LARv0b7nBbD4z13X+1N5nOi5ARvAskeoMiglpjzIKDHcmFG1o2NcY/SJ1MITStUBn 3FpEmURTeFaSBHK390sy6B1jKjTTXeC01Vr3r/5H44MmYmtSQX4ivCl0HDmjkyrrMO0E qy/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RbwUCO9/Da3fkPFh1nSPQACB3eAOSELwsDKteGbFH3E=; b=A9XMMcAb97v65rW4EH0ED1qDfVLPlfiZwjpLcB8K3KRKUSkd7XqhHi6ojYivvt50Nx yi5QA3BrL9Hzaoy9OEom5wrXa3hn6YQ9EoM1/6Do/xNq7Y2XTvOlxSvpUIw0lpAJ3yU2 WWNbOIVoua/FKFiqETaR/Xg7WMFMPNhma61GS4Ej2DthD9Njd2dvL0tkTrc5qD0cA9yH 9zXkQNxLcyr+SVdPv4wrugOGAR9tavduA2VOPmQAjSNsRa5MXS67UCqozR/FFDqbVzy8 CaOHefggY/ntIrV+clpxENwtaNNbB6LnAI6/UYpf1djX9rbSMpXvkWyVVNMV1eP4Sa3p OaCg== X-Gm-Message-State: AOAM533WAdOO54g51RuTR+rTlYZKubHrR6z/Pja901+bdUPtXimm4ida jOB6jCzOzDG/Aldk56HN03Q= X-Google-Smtp-Source: ABdhPJw4hRi7NpG5o3EaGOpeBH/XQ/iD8J7u0onTElKJ5yQng4S37msPhUXqPtYKnXUDaW7C3CthBw== X-Received: by 2002:ad4:4bb2:: with SMTP id i18mr1151089qvw.52.1605206503106; Thu, 12 Nov 2020 10:41:43 -0800 (PST) Received: from localhost.localdomain ([2604:1380:45f1:1d00::1]) by smtp.gmail.com with ESMTPSA id s134sm5591710qke.99.2020.11.12.10.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 10:41:42 -0800 (PST) From: Nathan Chancellor To: Masahiro Yamada , Michal Marek , Catalin Marinas , Will Deacon , Russell King Subject: [PATCH] kbuild: Always link with '-z norelro' Date: Thu, 12 Nov 2020 11:38:40 -0700 Message-Id: <20201112183839.1009297-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201112_134144_926775_01CF2692 X-CRM114-Status: GOOD ( 16.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Fainelli , Arnd Bergmann , linux-kbuild@vger.kernel.org, Abbott Liu , Linus Walleij , Nick Desaulniers , linux-kernel@vger.kernel.org, Jian Cai , Andrey Ryabinin , Nathan Chancellor , Mike Rapoport , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit 3bbd3db86470 ("arm64: relocatable: fix inconsistencies in linker script and options") added '-z norelro' to the arm64 Makefile when CONFIG_RELOCATABLE was set to help support ld.lld because ld.lld defaults to '-z relro' but the kernel does not use program headers or adhere to the section layout that is required for RELRO to work. Commit 3b92fa7485eb ("arm64: link with -z norelro regardless of CONFIG_RELOCATABLE") unconditionally added it to LDFLAGS_vmlinux because an error occurs with CONFIG_KASAN set even when CONFIG_RELOCATABLE is unset. As it turns out, ARM experiences the same error after CONFIG_KASAN was implemented, meaning that '-z norelro' needs to be added to that Makefile as well (multi_v7_defconfig + CONFIG_KASAN=y + LD=ld.lld): $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- LLVM=1 zImage ld.lld: error: section: .exit.data is not contiguous with other relro sections To avoid playing whack-a-mole with different architectures over time, hoist '-z norelro' into the main Makefile. This does not affect ld.bfd because '-z norelro' is the default for it. Link: https://github.com/ClangBuiltLinux/linux/issues/1189 Suggested-by: Nick Desaulniers Signed-off-by: Nathan Chancellor Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers Acked-by: Catalin Marinas Reviewed-by: Linus Walleij --- Hi all, This should probably go into Russell's tree with acks from the arm64 and kbuild maintainers. Cheers, Nathan Makefile | 2 ++ arch/arm64/Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) base-commit: f8394f232b1eab649ce2df5c5f15b0e528c92091 diff --git a/Makefile b/Makefile index 008aba5f1a20..648bfb486244 100644 --- a/Makefile +++ b/Makefile @@ -984,6 +984,8 @@ ifeq ($(CONFIG_RELR),y) LDFLAGS_vmlinux += --pack-dyn-relocs=relr endif +LDFLAGS_vmlinux += -z norelro + # Align the bit size of userspace programs with the kernel KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 5789c2d18d43..85495ff8f0fd 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -10,7 +10,7 @@ # # Copyright (C) 1995-2001 by Russell King -LDFLAGS_vmlinux :=--no-undefined -X -z norelro +LDFLAGS_vmlinux :=--no-undefined -X ifeq ($(CONFIG_RELOCATABLE), y) # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour