From patchwork Fri Jun 25 07:50:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 12343971 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=-15.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_2 autolearn=ham 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 BB085C2B9F4 for ; Fri, 25 Jun 2021 08:20:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 851656141C for ; Fri, 25 Jun 2021 08:20:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 851656141C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=synaptics.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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FGwlitEC/d4l8hNsLx6WiGHWFRdO0yk9GlXrH/TyswM=; b=ql4azOSd9BuVuW VDPo39RavUXdEg73Cm5MguSZE0CsbYWu5JCDnm9TNn1ZGmW2RzMzxn9Tkt2g6i9zTSKptu0W4j1zP m1bmHIWSw5rFM+P514uuLY/z//Gu+Ll+YOUkgM7WXSO3qTJia2x+5By22oSDyuglOx4WmEUZYQAYm v/+1jD1dXsFgGG9NzskjdxhofKdC/9w+vHn0nZlwJ89ueXery90KHE1hRpg4gbiFjlm51WG7xnIql e7/G0HywnkflndhiXUHPtnGqAz4gwAKkuQF1pc93f09Ex//nBS2AJsWWk4PGHON/LcVBp9q/9tmSm ZsGfjLEwXnaSQ85GkuWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwh1i-000GPi-5H; Fri, 25 Jun 2021 08:17:28 +0000 Received: from mail-bn8nam12on2074.outbound.protection.outlook.com ([40.107.237.74] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwgiI-000ASO-B4 for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 07:57:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OgeOMtT2or774+unO0zvKKs+YU0d6wonFbqPZsE7AFfSBtUrJoTdlK6lU/+DXlJXQDRQaZzoEo91qM9WBSKeF69mhMLxi0Jk7Lh/ft1oNqaInSO/ticAgzYvXktryFZZcH+qv1xsHgpONeBcq7zOtT1fZHwWRgAwy0YtMQQyfIDGWxu0WytHMfI1sILuSW0jNo/h7QDBv0TUxSP9dX2xnVUCVHcmUw+V0kdSMJg4ddKm/950P5PsUd5Bl/4NCzP0beZLj3v5kPpmdMAMFYzUcI4gKe8ZRZVCWBxuNBquIlEvvVmUr/i0U3hS4LLDbdIW6QGdPv3NrqLAVKhdmId4AA== 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=iRg/NoWOwWjjjc4h96e680DZH7H0iU9lI5b/g805M02nIWsc/91QaYJSPR2VyHTi5MBxfKSMe5AbWgYx/tcwAicZ5CQgShcQ6vqMQ5X+aL9fiBPO4+1QnkLpezwM33zwIG1+9Y9mwTIaFYI6cd5L5VECbBuEQY7v5ZuFzi2IToGE7kZsyj410mSJZmWcGZXZPmMBjLga+1mVKyLeIcxoxTQdpcAT5Ho0zsVt9EfO1YKVq2JRQ62wDDQl/NhZLzsBChxGVL/qP7vPU3YCuxSXu4VyUTryMGT1CixM5V0qMqxQg7xbsK7QQsjwGCOyGULV0ofvuSCxvEmBDXdBsT0Bcw== 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=VOxLsZlxllY75Miftz8l9LqXMwOxCqwGszT2/qvkJDCetb+TsEhMb3pofuGUPdZ0+nW2naLp0M41ooI1QPEARWfU68d7xJelLZXoBs7CCgajVnDO1UmQoScdoMc83ywQa/mCGtm2+U4c+LHRWiPj39fzZhUKD/eTxERU/oUb8/s= Authentication-Results: google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) by BN9PR03MB6137.namprd03.prod.outlook.com (2603:10b6:408:11a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.20; Fri, 25 Jun 2021 07:57:17 +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.023; Fri, 25 Jun 2021 07:57:17 +0000 Date: Fri, 25 Jun 2021 15:50:12 +0800 From: Jisheng Zhang To: Nick Desaulniers , stable@vger.kernel.org, Greg Kroah-Hartman , Nathan Chancellor , Ard Biesheuvel , Sami Tolvanen , Masahiro Yamada , Sedat Dilek , Thomas Bogendoerfer Cc: Catalin Marinas , Will Deacon , Alan Modra , =?utf-8?b?RsSBbmctcnXDrCBTw7JuZw==?= , Quentin Perret , linux-arm-kernel@lists.infradead.org Subject: [PATCH stable-v5.4 v2 2/2] arm64: link with -z norelro for LLD or aarch64-elf Message-ID: <20210625155012.4aec8450@xhacker.debian> In-Reply-To: <20210625154737.3d64a434@xhacker.debian> References: <20210625154737.3d64a434@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: BYAPR06CA0033.namprd06.prod.outlook.com (2603:10b6:a03:d4::46) 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 BYAPR06CA0033.namprd06.prod.outlook.com (2603:10b6:a03:d4::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19 via Frontend Transport; Fri, 25 Jun 2021 07:57:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 14318e6b-7165-4199-c414-08d937aeda0c X-MS-TrafficTypeDiagnostic: BN9PR03MB6137: 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: 4IV2hppgoe4nxQaMeQnnFa7NB9eZC8lq7K3BWtHf/49sQQQTsA6nBqFkajLC19zPI1GEtEFVNvziGPJBeL7vuPU052hxGuif+Rm/nhNnZRme5J6t4iU9M+WxxB+TZRSit9mpSAx/G5ABIOPBvYOHVxCK3uoluV+/BWWj8rq8ua4Zl6G5KAXEVrj98hijiT5GKyi/nPMm8o1eGd3nYGTvBM0kd/bFNZD5+r6Yq4xFyNl7p1iVAtlNRp6yorJha8zTOZ95niEfYxjkSrL20YNhDTQY+l+eOs6JsPsRISRTiNlpljmd582bJedES8rCtPWlUL2Bu+pPOA8m697kPPDUMH71bHmn1Nt49Kb/w0Wy1BFPX8GxlvAuzKwdRHkfPzLnkuBX3//ui/n97QMk9VVNkme+XxUNejHLS9hqWNGqjR3CCwab95Aq3K8Om0DSsh+GWfK7JNWsgMY5FSQArTNsdiEWVL6zVY9HLJLPPnfIaF0Zm8HrwL4p5MPNNEbpSl2wzysqFcFqaxdY+Vkm10nW7Lc/n9my0Iq4i2BnZlfO4wgJeFf302TpSDHwgQErNYvZZYpjjjuYw9J5NzrSfxNrUI3F9u9Axgh6tpQphtwjQi3fnL3ME+6yP6034CVZ3+Os7PlObW3kZLNbUqv9wEWlRayj5mm/cgrpXUay3P9s1HlxGMkwAFmc/QjpyAXAh1ZAhmOmoORa5I7CkDZoYzgrKCu9bXaO8+Yi/y1kGkWzQVpMqil5WAGVEEyTlQ9S/1EqxXYdn+dmS32UOS03zKaaHJUeSerVVORuZgThZiwMKV+RIO5ZmphyeG2wJCwr9mS6Qvl7NJjd2RTVuVeNyiIqFg== 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:(346002)(136003)(366004)(396003)(39850400004)(376002)(52116002)(2906002)(186003)(66946007)(316002)(66476007)(8936002)(66556008)(7696005)(26005)(478600001)(55016002)(5660300002)(966005)(16526019)(66574015)(9686003)(110136005)(7416002)(1076003)(54906003)(86362001)(6506007)(8676002)(38350700002)(38100700002)(956004)(4326008)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?O0m7ptXkaEA14l/QBPWoEWMvNNDp?= =?utf-8?q?OYpGNUC8aBFxKB+Ns0I2zZEjmPEDwwGTyaaBAKG4/Y2OzsKX5k3RGXg4BdMrPuwk9?= =?utf-8?q?EjTBioh/WQevuHwFsRKUMlye7NmWi8qWzbIJVYIyoeQTP1jpqb5uqZCHVs7fcKfYU?= =?utf-8?q?nCN5zYVWrdEt/urBCAGV/uB8/azPsZF1p/wOGc9Gea53YIA7QxqXk40fs5049OywN?= =?utf-8?q?by0Un1UN8pTLHzxPY6Km1OltrTyBxyrv9aeaJeEl/V9ggGj3fYvOrOPoUY/7FHjaL?= =?utf-8?q?Q2wiHX2HDzziqk8oDnYiivf46QCDfgxz0w4V68+1N0GgHLc+qK+nDd5OEjkLBBQHk?= =?utf-8?q?ZlLFSd02KchBYY7ANAGPP0JOwgDqUhNFnuUoAJbIDLi409MdrYetTX9LnWPxezkFo?= =?utf-8?q?ZwQR02gXesZdnbvpNysysRPKdBSCmemmrQAIguMuu6EPpGLGeOCKYVuE6sIdYpb2n?= =?utf-8?q?gvMhO/bVFb1mw9buPR9lBHWOIFInzrAkmRRbSmymf+fwzCiW4VRIycKQhrdfAkq94?= =?utf-8?q?Q6PykG0+k1++OAiVvr6uZi38LNw4LK77Pw7GFi1e+La7qs1/VLC4x48nxE1pEEib8?= =?utf-8?q?w3X+thGs97CPr7OftQQvWnwIkG3Qr5oXngBOHwCwdI4K6m/BOm+k77bef57zeP83f?= =?utf-8?q?YSTed084y3zNCdkMEbwtaRCYS45C/GysOFoe7mglmv39JDEZgjuSCwPfachZumPip?= =?utf-8?q?QbdJeKf9xDiopAsMx7DzCsT8z9IJeTcx0FN0yHJYkfFDOVER5tD7ctK/9PaFI1n2j?= =?utf-8?q?546/OuWSq03jpxmwYu8XkfkwHmTuOAzTgBUhJPL1T7knh1PloXJM6umbVqfLR9bDa?= =?utf-8?q?d0rMBo1gxwQPTrrMx7ZXTLEMnO8N1+7VxcTq5rB/e5WuVf/ye7LWk8deLS3poOrZ7?= =?utf-8?q?4X07tx+Un2dM764K0TKo0PSkqpJSrLKK/Ow1VVaJ0ND1tiICIZ5NwFAqzNNxisRPE?= =?utf-8?q?6L0DVv+m4pz0O3GuDUTMRnDt+xZVk/gWMKfeXzy4gYmYpibNE2p+B5R3N8f1J77S/?= =?utf-8?q?aZVHIbXFVoYzse13I932T2IAgqTn59qe1FTbSgt2Vw1fa9JfUfgQrAgqQCMjS/5Ab?= =?utf-8?q?CRMprwleW26U4kZ5PaCFfqOAKos5uMfqQECA+aB5qGV7LtgeI5oNpW+5hw/teQhhn?= =?utf-8?q?MC0Zsm18tDftmddPWYYXahcPRr4ouiFiUcd8iFAuTBqAkcjldv7uEwx6TvZ0N9vVR?= =?utf-8?q?V6UJ2ydBiJseiITfPYncIuLtAiaYxj03+U7ptV3iKZir+Vl1rzlzyIJwWMzHss+KX?= =?utf-8?q?CQNZ8tHs3lBojzTJ?= X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14318e6b-7165-4199-c414-08d937aeda0c X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6058.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2021 07:57:17.3564 (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: a6mkC3YbMYqKDtHJMwrS7s2vECuequtvWIK1c2lqqXUHECjjdW4p+zaAEu4V890BGtlktBsV7acKOQkuFvxxdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR03MB6137 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210625_005722_490422_5FB008AC X-CRM114-Status: GOOD ( 11.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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(-) 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)