Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp577207pxb; Thu, 12 Nov 2020 10:43:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkiI5N1QE9fa89Vz/pTY0ZJmQtgPXnKb5HF4G8rTHfibqJJpD9p9qjLpqkzBRhe8drkFtS X-Received: by 2002:a05:6402:1042:: with SMTP id e2mr1310709edu.320.1605206638348; Thu, 12 Nov 2020 10:43:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605206638; cv=none; d=google.com; s=arc-20160816; b=lSQR9sSdrn2ML25Ht6JUFZmYWz7Nk2cYRBv3NAClY5mZcmSHyOPHyAph1cqAWkRGDY a/Sn4Des89XmHZZzpp6mBRi56Hwy30VIdQ1j9w7uzoBQlcy92vDRx5DMX6Wx/4ludcEw Yz6zv7AhpYP7c313BlvUSIg3FwJrcFhOzqNbBq+O2SqdDjvhPJ6z7zohK+r/QUmZvQAz xMls5Ss3PQLtlzYwgM3vaxDKZ8C0jOdK3qZCK/pzFqCBEn2nyjUU6O1gzCeVDFxyW6CU BZVsjYAYY8i2C0MFTfoTXIIC99KoIL394XeADXQOMG4DzQl+Xdjyhv0CRhzee4Ho+6vs qqSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=RbwUCO9/Da3fkPFh1nSPQACB3eAOSELwsDKteGbFH3E=; b=RZ6RMEL2IuIa7dv02MhEKM20NHFy2SuRgar1k5RGfK2xJXGtxuDpaFlUjUV4w0ZCrw xyfAg0AQq22X6wDdFhFylBjMYdGSi8AUtQ/Uz3an04cyLQ3YvQtd/sMrSEQHaJVxjKjQ 6IBuHHfaL4GKQHOddR/+cSInSfsjlbrO3dUu4uxaPCluGrxRUl30IrjBPeBzjdjkz0e2 F/YtlcnOLzJb52u86nwSuGuA6Ca4LHf41F1tzrYqYheuvpNgRVc6MDSbu/Nikml5n3Ak o/qqglvxvTZUCnkvGGOyNuxJUc0iwP+6Wjrq9nQ6uk8clI/yVfNATGnUz2U3Q/C6VHoA SrYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=myShStDY; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lj4si4519148ejb.289.2020.11.12.10.43.34; Thu, 12 Nov 2020 10:43:58 -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=@gmail.com header.s=20161025 header.b=myShStDY; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726560AbgKLSlo (ORCPT + 99 others); Thu, 12 Nov 2020 13:41:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726303AbgKLSlo (ORCPT ); Thu, 12 Nov 2020 13:41:44 -0500 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFEF7C0613D1; Thu, 12 Nov 2020 10:41:43 -0800 (PST) Received: by mail-qv1-xf42.google.com with SMTP id ek7so3277113qvb.6; Thu, 12 Nov 2020 10:41:43 -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=KhClIHeLmgP2ESNYdbU4MDosSISP7Qm2lb6jafNOsWkS1KEY2jnnO3ICgUnzCzXwam oH+g6HjJR2YE7bwRcj+7GjbC2JIY+S8tMbGZtfhaPQd8VwkwnQH4WCzXMWZ7Pgt+FZnK HZ9MCtDJVTuTfCfGy4jFHic5bri/TqTFUDIy07w0bpltiq9iODLjsMMe4TprHzpkO5j+ SC9hVavxX69rzZb58k6G8TfWU3Wc2ZeWSn0xpcFS3gwmZ6YhyEE2MMCe4VPrspizcIZ1 dN4bQI0eOpVSWsga/H9SZLZoxgmBO3FgZQXb1xAGYcWCZ2NMMRDPDQCb1zo/eOw75aUL p1rw== X-Gm-Message-State: AOAM532ImM/jJGum8O6HXRxJrcRDo7SO/kUGHwdw4Lz2uD8YSoEGkD5u nWi+LV4st5+dj9NJAGJCNWI= 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 Cc: Florian Fainelli , Arnd Bergmann , Abbott Liu , Linus Walleij , Jian Cai , Andrey Ryabinin , Mike Rapoport , Ard Biesheuvel , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Nathan Chancellor , Nick Desaulniers 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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(-) 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 base-commit: f8394f232b1eab649ce2df5c5f15b0e528c92091 -- 2.29.2