From patchwork Mon Jan 11 13:02:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 360460 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp2505747ejs; Mon, 11 Jan 2021 05:23:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2lFl2Th6/PkpAQFmU7CQP7HPHWV4ttA2jYdUOKjiC4GawbLFZT9jxOQ4sfzQbarNVDFPA X-Received: by 2002:aa7:d94e:: with SMTP id l14mr13970439eds.98.1610371399798; Mon, 11 Jan 2021 05:23:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610371399; cv=none; d=google.com; s=arc-20160816; b=whZPUfpwHaQOlt1mnLsJMyl9m9SLIhgghzBIh11cNm8PSJJWByrnu5NY5h9RZllxaV viezd5YFx+VXQf1ql4/TU7vchh3SWuO5yWB/OzV4X59/eokZZDRyCY4tqpqBMWfHGF+l NPHnUNAVdIVWIj9IDbwFkTODGJuiYIbUL8mPCjtmwvo1hU+utmw/qYOQ+aqQd/flzKIP 9chwGLd+8vJc/X4d7AGzPhbbupV5Qq6706KikJb5qvRVhzyoDSwqqFG32liB5mqISQWX SafIc6MuBE/2quwBJ9n7509Ksqyf0ZIB9N/LB0hYcaSIq1mK/KrHOOmJu6rB2gt1Jd1L NEIA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VHyO68w2yZTYlekA7ArFTLuKiiflU2XYqBQXTGAYT7k=; b=FJC8vBjcLaoCyNxbMaZwZG7S03e9nC6OuY7fvFfKSFasj2E1F6+wSDmbwd/pgSH8IK DAOWrjnkM4QjAceztSTePoP+/oRKHFeeG6DZUuIsGTWke+4aRkQUjPwRl1EPhGuE/q2V TftzV+FkIDN+2C3968RUnOKM6xMFW86ctKdL7HNc4pv9R1qgKM41v+RktriKtPpyJDzL D+eQUpuFgn3t9pUSDP6EqqopbbhHQIvochl9+p0rohBwRobW1qagxEpZzOvJYM8p3Cj9 2D75aZ2/5Q8k5s8gztcMvef49t6/rgul06XnIezMWKubhTQp/iY2wSSl3AxqgzR4ORea ijNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qFFyjMZs; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g3si6449000ejw.12.2021.01.11.05.23.19; Mon, 11 Jan 2021 05:23:19 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b=qFFyjMZs; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729918AbhAKNVn (ORCPT + 14 others); Mon, 11 Jan 2021 08:21:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:37532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733244AbhAKNTN (ORCPT ); Mon, 11 Jan 2021 08:19:13 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 60C2022A83; Mon, 11 Jan 2021 13:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610371112; bh=xZJ4AxdMJDxWjNqQHP2cu0DDr9uFvEAqpMKQt77EwSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qFFyjMZs8fkwBw3Ey/Sc7gnhbWcDQibnmORjqfgrxaG+/gfH1OHYtJQQnwVhdDATx ewC0yyRXbhCYWel6EepIbUihc/iAufO8C5q2a57xWRAICRhp/kkdFVA3DDPvnmoQzO /DVQ1AeYD6tohXBB5Ek/0Fi4kiwcuXehfsoGkw4E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "kernelci.org bot" , Quentin Perret , Nick Desaulniers , Nathan Chancellor , Ard Biesheuvel , Alan Modra , =?utf-8?b?RsSBbmctcnXDrCBTw7Ju?= =?utf-8?q?g?= , Catalin Marinas Subject: [PATCH 5.10 129/145] arm64: link with -z norelro for LLD or aarch64-elf Date: Mon, 11 Jan 2021 14:02:33 +0100 Message-Id: <20210111130054.714929856@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130048.499958175@linuxfoundation.org> References: <20210111130048.499958175@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nick Desaulniers commit 311bea3cb9ee20ef150ca76fc60a592bf6b159f5 upstream. With GNU binutils 2.35+, linking with BFD produces warnings for vmlinux: aarch64-linux-gnu-ld: warning: -z norelro ignored BFD can produce this warning when the target emulation mode does not support RELRO program headers, and -z relro or -z norelro is passed. Alan Modra clarifies: The default linker emulation for an aarch64-linux ld.bfd is -maarch64linux, the default for an aarch64-elf linker is -maarch64elf. They are not equivalent. If you choose -maarch64elf you get an emulation that doesn't support -z relro. The ARCH=arm64 kernel prefers -maarch64elf, but may fall back to -maarch64linux based on the toolchain configuration. LLD will always create RELRO program header regardless of target emulation. To avoid the above warning when linking with BFD, pass -z norelro only when linking with LLD or with -maarch64linux. Fixes: 3b92fa7485eb ("arm64: link with -z norelro regardless of CONFIG_RELOCATABLE") Fixes: 3bbd3db86470 ("arm64: relocatable: fix inconsistencies in linker script and options") Cc: # 5.0.x- Reported-by: kernelci.org bot Reported-by: Quentin Perret Signed-off-by: Nick Desaulniers Reviewed-by: Nathan Chancellor Acked-by: Ard Biesheuvel Cc: Alan Modra Cc: Fāng-ruì Sòng Link: https://lore.kernel.org/r/20201218002432.788499-1-ndesaulniers@google.com Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- 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 @@ -110,16 +110,20 @@ KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__ # Prefer the baremetal ELF build target, but not all toolchains include # it so fall back to the standard linux version if needed. -KBUILD_LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb) +KBUILD_LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb -z norelro) UTS_MACHINE := aarch64_be else KBUILD_CPPFLAGS += -mlittle-endian CHECKFLAGS += -D__AARCH64EL__ # Same as above, prefer ELF but fall back to linux target if needed. -KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux) +KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux -z norelro) UTS_MACHINE := aarch64 endif +ifeq ($(CONFIG_LD_IS_LLD), y) +KBUILD_LDFLAGS += -z norelro +endif + CHECKFLAGS += -D__aarch64__ ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y)