From patchwork Thu Jun 24 09:09:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 466339 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp266121jao; Thu, 24 Jun 2021 02:09:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3UXnGY3LzCJr5LpWkCz/1JD+LuwUTvE3d7rFyk7tYwY29ZEhPMwvzUG7W1K7L02DkP5en X-Received: by 2002:a17:906:b0cb:: with SMTP id bk11mr4399908ejb.310.1624525775215; Thu, 24 Jun 2021 02:09:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1624525775; cv=pass; d=google.com; s=arc-20160816; b=ez1V7f+ZZDVxa52KsBwq19mK4wTioWJBE7szkURYwMYMdBG5B8AeFwZBwXUUhr9Fa4 uh4LGsmrFbAszlhqsEppcQMpqV8GMo+jqfuQh1F1dXtiyhbdolZIOuzrSo0vheGUx4hB 8VI50X4R1mRsS6Q1pSSqWBEcOjBYTrSbXyERDS+KuuMgNExXrK8nePcU3WXxDhaF5FSL Wl/u4+NsjVFQ4vqSa9IvE8wQ6ggT0BUZuRMEmDalT26N1VKA7WH/YyI4XExb+f1EPqag vYSoWBjHdquGeHj/P0WHiC/GRT0opYFLoM2rucIjrwqrYzI/Xf9rUqSD69Kd9Ooh84cF pXeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:subject:cc:to:from:date:dkim-signature; bh=ntAtTCMcbHSjuDHVGPGm1FRLN0bmiJDw3df60Y/3c3o=; b=ETXk7t7Ex1lIT1BwncINTAeA5F3otoQkCr7yk6C9W2i5VAnUlHjxpDsgtQE2GIuZaK nCdIpbQW5ZfKhjp86fLII3MLKTPbtrwNM8/sbsNEwVKDUBj3e8Tf7ZwSu4UVsZWns3GR zhTIaSBKmQTvjavmDgwKVsf4RDDJHdZbnU1n/ZvKYdrZBs3NtatO2uFauahsTykpPPkJ DJeATpvASyyYqX91cFju7Nt3P2QW/pod9RH1iQuMOFb6WLRPIoTCRbfymGexl3ptr8Bm OmfSf7lhSFhS9cvAvFDSIVeFyiDh0relEZx60kdvNe8qKxUN6QAySA4Mz02XhrT+8Nw4 5prA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=jmEW5CFR; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=synaptics.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jx14si2328860ejc.721.2021.06.24.02.09.34; Thu, 24 Jun 2021 02:09:35 -0700 (PDT) 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=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=jmEW5CFR; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=synaptics.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbhFXJLw (ORCPT + 12 others); Thu, 24 Jun 2021 05:11:52 -0400 Received: from mail-co1nam11on2082.outbound.protection.outlook.com ([40.107.220.82]:17697 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230102AbhFXJLv (ORCPT ); Thu, 24 Jun 2021 05:11:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iW2d2nnc2S8xj6t6S253Ad7kIZWjzdzJNnCPA9srIA3kBxRc9q+Q6Eohrea/ePjtc9+SKxPsKN4TPPm/EEZWWKj4TdT9T7n/HuR4AvR4PKPRXgwZaBO3yvphUt39CEnsvPNAWze0ZyLMtuQZ1E5f2a6QTTDBOD6PSEUMvZSh7i/jm2Yt7Oe6iI4WoKkTbIfd7SLeX7ZQZTEBtHcLd9zEQiZhgpQ3jYZq9Ez4n6tcFFlmXcrypLeSzi0ldy2tqPHESFefNN8DbWs5zrFzAWtkmMC6hW4oT4z4rnufOg6ZL3oQYV47RdihAgsN5MOqVWowQ/0vc83tDxpW8l2uNTgACA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ntAtTCMcbHSjuDHVGPGm1FRLN0bmiJDw3df60Y/3c3o=; b=UAxK5d3q3ZkLr7USZmSxs6RIzkGgwaDR4qClgrHZvuGKUHZ4YNJOptwyqVKq+uCvHVuvzcqHbOEwKNMNwRoqoyiltUikgDK3X+27+oXCk3VT7ZTvF8j7GREftiN7dR5Cj2JXivH+0TUUoOK+db0SCXLNPEWePSRz2WxcOJHupxsFTQGzvpAFYnYTePf2ktI8JM+EneQbM+wFMSyQNcL4RBE2z/Kx2UaevOlIXdMuNgPy28Byb09kTlNfcgLQjO0OCiQiAxXw2xHd8k0V76UObFhaYsZYT++0j9ucZEEMkOKLclLRKKJwKs4UrnIdS9hAZcdVdG7zle6XHd//0SOrjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ntAtTCMcbHSjuDHVGPGm1FRLN0bmiJDw3df60Y/3c3o=; b=jmEW5CFRVk7CoY8wxiXMAeLUCxnOzuAIkY6N6GbB1npmWRLZkIW6FFOrVJ+/iioWa36JABDHBprcLM/mcp2TqLulhIBq+lqtEPNKkyFDOA9xU2EtFaRrmMZ3N8Zmxh69T5usyXwxH+YTnDMreTwmGbpSONWfp5MGh1ouZZx5wXI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) by BN6PR03MB2914.namprd03.prod.outlook.com (2603:10b6:404:119::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.21; Thu, 24 Jun 2021 09:09:31 +0000 Received: from BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::502a:5487:b3ee:f61c]) by BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::502a:5487:b3ee:f61c%3]) with mapi id 15.20.4264.020; Thu, 24 Jun 2021 09:09:31 +0000 Date: Thu, 24 Jun 2021 17:09:19 +0800 From: Jisheng Zhang To: stable@vger.kernel.org, Greg Kroah-Hartman , Nick Desaulniers , Nathan Chancellor , Ard Biesheuvel Cc: Catalin Marinas , Will Deacon , Alan Modra , =?utf-8?b?RsSBbmctcnXDrCBTw7JuZw==?= , Quentin Perret Subject: [PATCH stable v5.4] arm64: link with -z norelro for LLD or aarch64-elf Message-ID: <20210624170919.3d018a1a@xhacker.debian> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Originating-IP: [192.147.44.204] X-ClientProxiedBy: BYAPR02CA0039.namprd02.prod.outlook.com (2603:10b6:a03:54::16) To BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from xhacker.debian (192.147.44.204) by BYAPR02CA0039.namprd02.prod.outlook.com (2603:10b6:a03:54::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19 via Frontend Transport; Thu, 24 Jun 2021 09:09:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 46bb5bfb-a4bc-42da-b8f1-08d936efc6c9 X-MS-TrafficTypeDiagnostic: BN6PR03MB2914: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y1L8T87OsiFWNTGX9Od13IZ52Ka9q6uSA8gLZQ6QavTsMEElxUq3qIrjAsoObpK0sKZLavk+tD/Q/hD62HrCUQnJKDn7nYBa4n4A1rllArAl71HcokscVfU26WXi6IHr7E88mUPu77ZuOsz5Y6vSKpqUD1aKVukQgTu/hyTt4ZxbNNHlIArf15L3gmM5bj/FWKUpQK0V8OW4ZOuowTaXDk2WHRJ5w/EGos42gPEbbP42V8e6+RIBb3QVVBuklczF9FjdbKwf7DIjl3ylIpWAPj6cQirI3Vl2rRNksXSCMx9eDYReamFYdKdAhd7ycdR5tpCxInez0vFaG5IagEnNj9Y42NWYsYIHCnX5BRcqrx/KfM9PNfYmeep4KddO7Z32EwHwbtInjp653pQ87/CYAR4F0oJ55fGn0DfWcHDXe4P/FVzpg+cc3+dTPpcBuXj+8RaeQNkSDlj9NkTu4T54vulP90F9FUyY277xSfU9sKDFzpz/2x5stHZaX+/PIBfNAuiubG6aSxF0u0DneitXMpOkrK8rW7irH/p8S3WT+UySrJcxlW+QbXMdLXWvgN7BZVot0vbjvZ0witWgzDNu3Vrjm+7QfBbz4HkHtcRSDNivIxkI9oFAICQ9DdbcdP4eW7OmB0vbUvtcix8udD1T0Raf6bZrODoCvyrXWw8L1eOKh9Squ3+DOarqMQUJT8LDBTQ7427V8ajLeRXU4savHNUkcaQtx+MZDUr/2Z3mpWyTbxbSdnq9PO+ZSmSQumTojdyRreeYfCEmgxrSbz17jm8jdf8EV2CvBkWhft0/apU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR03MB6058.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39850400004)(376002)(366004)(346002)(396003)(38100700002)(2906002)(38350700002)(316002)(1076003)(86362001)(8936002)(6666004)(5660300002)(956004)(8676002)(186003)(26005)(83380400001)(66574015)(478600001)(16526019)(4326008)(110136005)(966005)(52116002)(7696005)(66476007)(6506007)(66556008)(55016002)(9686003)(66946007)(7416002)(54906003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?I50rMtKdvaj3Cd53i8os34cfj?= =?utf-8?q?bJUtgC24/Pm39FEF0tJ7Lj16p3AfmzdGtz1R8jIJ4em5p2dWfAcdik3g?= =?utf-8?q?JgToG5xoxu0vSh/pbVht/3jOYH36Gau9xXv4ihWqACY6VEpStllPycyd?= =?utf-8?q?DKmLIwYRL+V9+G0FMwkWohy/LXblqMdJ0VkblSW/wEYkrA06rnExbAFN?= =?utf-8?q?bWxEO8HE3bevw8I91E95TmckQml9QlOEM5uqh9GadotGCg5o9u+DpACV?= =?utf-8?q?1dKZ8B9DlJF6GNZT+Y8NZzXnZxtmsATVyEZVxje1DHvzkhqjwa1/27rN?= =?utf-8?q?P2ipfDFd2OyNNr+rUzKXqwxycMo+LX4Mjf7De2FzmBm4btuJu7fx79Qh?= =?utf-8?q?eq4FZxASGEtpvCuS4oRgVJUYVr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pTCxoCzBzVqTPZPgPbw8gZKL26yH6Ep4dSIqduldc7DzMwdyA?= =?utf-8?q?338aNTtho6WITREefQgMaQG+F6V+wyD?= X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46bb5bfb-a4bc-42da-b8f1-08d936efc6c9 X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6058.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2021 09:09:31.1102 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sea1ax7A2VebJn+H/wjvWtYGO8PojUTmjvhv0cV+afovydfRFThWm4fX8ZzCUzckZZKUtOErvQnnggklDf3C3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2914 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 --- arch/arm64/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.32.0 diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index cd8f3cdabfd0..d227cf87c48f 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 CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET) GZFLAGS :=-9 @@ -82,17 +82,21 @@ CHECKFLAGS += -D__AARCH64EB__ AS += -EB # 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__ AS += -EL # 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_ARM64_MODULE_PLTS),y)