From patchwork Tue Nov 3 10:25:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 11876617 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=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 BE7E0C2D0A3 for ; Tue, 3 Nov 2020 10:26:47 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 6E1AA206F8 for ; Tue, 3 Nov 2020 10:26:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="Eq8WzEuB"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="Eq8WzEuB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E1AA206F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-20323-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 13653 invoked by uid 550); 3 Nov 2020 10:26:39 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 13629 invoked from network); 3 Nov 2020 10:26:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DA/uKEqYFIqv4yw/4vuKz0cdGhH9H2bnFuZnjVQ/Wbc=; b=Eq8WzEuB0TdDN9OLkTfgMfcLPE7sk9093wOs04dOGlFUd4eVfBKaQmommKTwuFZUUNS2wAKy6uRVxz32FZSGlegzEax/rIE2WhQfS8sLr25mxqDgTgPNkW0N0kSBGu5rO0vP7zhvvdou9rQjIGDMW1B5nKVGuEGPb5yVTUFnNAI= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.openwall.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.openwall.com; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 1b7fbd5d4e494ead X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KKyYgGMMKnI/dqhwGwOJ83t3I8qrN2728qtg6W6pgxyVz43txLL5KiRmC8aYXkqX40vaLyJnB9scgmb/1zfVv+1gFsafEaGWJarKMJNyvJpmVHJ22JegV/Wq+vbYLX6ensCQU/XkgN6OZJk1zit2nGbkQybbGCBpMeY6+n2iMPpuo8dd6K+mdB0w6/mTftgPBGp1bxe6HfwkOwVi8no5dicCqDeWJU+qEpmbNZPtcCua45ksq2FCEcoEznLVlb2c4EZy1YbkFJBMxlPkABZoRZ1EMEnHI4q06dX/PWRmNdPYi6PyDJAOISi9AeZtglV6qmMJDomeLKfl+6LOSIrLxw== 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=DA/uKEqYFIqv4yw/4vuKz0cdGhH9H2bnFuZnjVQ/Wbc=; b=Ki24zoZFsLrzrB/EJMZn407u9N0uDZdI7wCXYcogz4RwNpVa4kHUWH6nBLNlJJqZEbmxLN75FX7loYhTR30UwqgC/dPOOwSazJUeJM4nse0IAmtFftgJhahMdpQmbzQWarQ+YODYT8iu7vtDjPT5UiZ9w+FU1W4+6IhPeQ2aSWMKg79it2Ckl6gEAMDyH6AwmsC5U26SlMOgqJHWVKvehKKf0WII47+/s7AQL0+dptFfk40RuI1SojpfxQTEnjGfBF7egUDSdIV0fIeT1+YM9M2suCcmewzvwzRydXStJJ2Q6KshIbve5L0C4CFUl2s4VW7b6iuBS63CBYRrAELgvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DA/uKEqYFIqv4yw/4vuKz0cdGhH9H2bnFuZnjVQ/Wbc=; b=Eq8WzEuB0TdDN9OLkTfgMfcLPE7sk9093wOs04dOGlFUd4eVfBKaQmommKTwuFZUUNS2wAKy6uRVxz32FZSGlegzEax/rIE2WhQfS8sLr25mxqDgTgPNkW0N0kSBGu5rO0vP7zhvvdou9rQjIGDMW1B5nKVGuEGPb5yVTUFnNAI= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; From: Szabolcs Nagy To: libc-alpha@sourceware.org Cc: Jeremy Linton , Catalin Marinas , Mark Rutland , Will Deacon , Mark Brown , Florian Weimer , Kees Cook , Salvatore Mesoraca , Lennart Poettering , Topi Miettinen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com, linux-hardening@vger.kernel.org Subject: [PATCH 1/4] elf: Pass the fd to note processing [BZ #26831] Date: Tue, 3 Nov 2020 10:25:58 +0000 Message-Id: <31936e4acedb265ad49d04f7789bef09d6578448.1604393169.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: SN6PR05CA0019.namprd05.prod.outlook.com (2603:10b6:805:de::32) To PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 49168d11-3278-4feb-4f42-08d87fe2e926 X-MS-TrafficTypeDiagnostic: PA4PR08MB6223:|VE1PR08MB5229: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: AaxZiJ7jdnYp8oYD2ZDBf5QY4DECjO04ey3y7RDl0oTDJTGmqCY+xJtoeab1SQ/opSeIsmOdH95B6FXKdajRMViBb6frjEKss63aZKt6svL+EwUnYdDYtQa9c+GZsbJJhRzQzQxLR500HnSBqbA1vqByjX1zi4EWyFnhAwsrHgOoVYuiSW3qC+pHZrMbnyd/YdqiVcv8tIP9ZUtNWc3Qs7W6rVqSo4fr93kioTeb+kgoYW5D2ysQFwTyhqtgBSvbMGNqdna38Kk6x1cZC3ts6J9vxdHxltY8oD2I0wznGuA5cvBr2sP4vBTAk4UGe7B2VkNJwFCYd6nBmyrFT5o99pVug4VYnL5i03uDM78aIdLVY85JdEF+I2l1GkHqHl8v X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PR3PR08MB5564.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(396003)(376002)(346002)(136003)(366004)(5660300002)(2906002)(66556008)(6506007)(8676002)(66946007)(478600001)(54906003)(66476007)(6666004)(6486002)(4326008)(6916009)(6512007)(69590400008)(186003)(16526019)(2616005)(7416002)(36756003)(956004)(8936002)(86362001)(44832011)(83380400001)(52116002)(316002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: sDODfNVK6I1Y/maSwD9fiqG+WsIIHDnTIDBUyAnsUO3P9ydzjO8R2e3ZHV6s3M+/aeO8WwB5dyZpuEa+CnFqYwJf4+df5QhbII+ZXY7FEAQsH120aHjz1GRbFAv3ftwh2udUaQbBtzWZDCPjNCPl6SMgucF2FCyXAIj/PaGF5skh/5+mhok/QsBP1LHtQhdk9y18xLf30TZXUCcZ5mcjrFe6viDgSWbjvB6R2rhHqtS/iTOixIa/KWzSoIdaY5Lo9cfss+5D5FGaycYr4sderddscABk9SD1cOGahFxf8a7lERQpCQMSyVSpv4mWweFo811P3SAFTrQu1GXFk77hQnIVMj7eoydL/vzATdYpc1i44otgFkMGkRJQy2lH4wjaX7BvApHbxoEvsUQ5S9ky+Bvx45tzPIh2dSNn8kv794dojyEOU8nv8MJg5uKyRcEF3DhFJlbtNbeRJfTVxiD/qtOcALiPGhprsvxXMOfuxgIU5xgsdW341fhSywjjnAxIeaIsLrSgy6obGJAfnq61CWIM3NJ5FT41eRnZbEeL3+k9Y2WT62vRWY21dKX4Jfw0niZ7luXX8KNJvBt+lKNXLyqotlGjHZnfeK/ZIGJUKilvH3VSP5DdgjG4UecSp0rC9GAEHFkWIDbmHAv17cVF0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6223 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8914356f-c88b-4471-257d-08d87fe2e2d7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s5HRwqG9gUAwTW9y1X/jXHhEMqVgP/nwZts3UANnljlCMhzicGG/Ar5X5LPTdKl4n0BHQCdE/4HPJWQWCXO/WKRGIvDcTCMQuSez67Clr95uvlbi8zM/9DXVdijQkB2eeG179TWUEaVr46SRkmVEUtNxd2YMr9XhhtkyBd1V2Zl1JuKD6Jhh1uh1w/uW/XgDChTf/McHg4lJMRZDxjPkN9OcyBnhdm584U75LkwSPJn+VTN8olivZcgI98zr95PGxwXPMyI/HjNR6SL6fP4dwPnfEsa/PAABOPR3qQ7pGGHBt4iHFGLUMRs6Kb7qIt/CPg5xGkwvFNOft8vVnFWAxwQkr6D7I8QL0BT5c5JNeoo5zepbCCynKslefmXPIsVW0MtlaDYUhB4XnZYZ+DjSjpisKSwrYCGJTofEpv4jRPG6wnV5eXwivh2g4iX11TlY X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(396003)(346002)(136003)(376002)(39860400002)(46966005)(86362001)(478600001)(186003)(6666004)(36756003)(44832011)(107886003)(6486002)(2906002)(54906003)(356005)(316002)(83380400001)(16526019)(70586007)(336012)(8936002)(69590400008)(70206006)(26005)(82740400003)(2616005)(956004)(82310400003)(4326008)(8676002)(6506007)(81166007)(47076004)(6512007)(34206002)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 10:26:22.3803 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49168d11-3278-4feb-4f42-08d87fe2e926 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5229 To handle GNU property notes on aarch64 some segments need to be mmaped again, so the fd of the loaded ELF module is needed. When the fd is not available (kernel loaded modules), then -1 is passed. The fd is passed to both _dl_process_pt_gnu_property and _dl_process_pt_note for consistency. Target specific note processing functions are updated accordingly. --- elf/dl-load.c | 12 +++++++----- elf/rtld.c | 4 ++-- sysdeps/aarch64/dl-prop.h | 6 +++--- sysdeps/generic/dl-prop.h | 6 +++--- sysdeps/generic/ldsodefs.h | 5 +++-- sysdeps/x86/dl-prop.h | 6 +++--- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index f3201e7c14..ceaab7f18e 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -861,10 +861,12 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l, /* Process PT_GNU_PROPERTY program header PH in module L after PT_LOAD segments are mapped. Only one NT_GNU_PROPERTY_TYPE_0 - note is handled which contains processor specific properties. */ + note is handled which contains processor specific properties. + FD is -1 for the kernel mapped main executable otherwise it is + the fd used for loading module L. */ void -_dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph) +_dl_process_pt_gnu_property (struct link_map *l, int fd, const ElfW(Phdr) *ph) { const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr); const ElfW(Addr) size = ph->p_memsz; @@ -911,7 +913,7 @@ _dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph) last_type = type; /* Target specific property processing. */ - if (_dl_process_gnu_property (l, type, datasz, ptr) == 0) + if (_dl_process_gnu_property (l, fd, type, datasz, ptr) == 0) return; /* Check the next property item. */ @@ -1266,10 +1268,10 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, switch (ph[-1].p_type) { case PT_NOTE: - _dl_process_pt_note (l, &ph[-1]); + _dl_process_pt_note (l, fd, &ph[-1]); break; case PT_GNU_PROPERTY: - _dl_process_pt_gnu_property (l, &ph[-1]); + _dl_process_pt_gnu_property (l, fd, &ph[-1]); break; } } diff --git a/elf/rtld.c b/elf/rtld.c index 5d117d0d2c..6ba918338b 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -1531,10 +1531,10 @@ dl_main (const ElfW(Phdr) *phdr, switch (ph[-1].p_type) { case PT_NOTE: - _dl_process_pt_note (main_map, &ph[-1]); + _dl_process_pt_note (main_map, -1, &ph[-1]); break; case PT_GNU_PROPERTY: - _dl_process_pt_gnu_property (main_map, &ph[-1]); + _dl_process_pt_gnu_property (main_map, -1, &ph[-1]); break; } diff --git a/sysdeps/aarch64/dl-prop.h b/sysdeps/aarch64/dl-prop.h index b0785bda83..2016d1472e 100644 --- a/sysdeps/aarch64/dl-prop.h +++ b/sysdeps/aarch64/dl-prop.h @@ -35,13 +35,13 @@ _dl_open_check (struct link_map *m) } static inline void __attribute__ ((always_inline)) -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) +_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph) { } static inline int -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz, - void *data) +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type, + uint32_t datasz, void *data) { if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) { diff --git a/sysdeps/generic/dl-prop.h b/sysdeps/generic/dl-prop.h index f1cf576fe3..df27ff8e6a 100644 --- a/sysdeps/generic/dl-prop.h +++ b/sysdeps/generic/dl-prop.h @@ -37,15 +37,15 @@ _dl_open_check (struct link_map *m) } static inline void __attribute__ ((always_inline)) -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) +_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph) { } /* Called for each property in the NT_GNU_PROPERTY_TYPE_0 note of L, processing of the properties continues until this returns 0. */ static inline int __attribute__ ((always_inline)) -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz, - void *data) +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type, + uint32_t datasz, void *data) { return 0; } diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 382eeb9be0..702cb0f488 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -925,8 +925,9 @@ extern void _dl_rtld_di_serinfo (struct link_map *loader, Dl_serinfo *si, bool counting); /* Process PT_GNU_PROPERTY program header PH in module L after - PT_LOAD segments are mapped. */ -void _dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph); + PT_LOAD segments are mapped from file FD. */ +void _dl_process_pt_gnu_property (struct link_map *l, int fd, + const ElfW(Phdr) *ph); /* Search loaded objects' symbol tables for a definition of the symbol diff --git a/sysdeps/x86/dl-prop.h b/sysdeps/x86/dl-prop.h index 89911e19e2..4eb3b85a7b 100644 --- a/sysdeps/x86/dl-prop.h +++ b/sysdeps/x86/dl-prop.h @@ -145,15 +145,15 @@ _dl_process_cet_property_note (struct link_map *l, } static inline void __attribute__ ((unused)) -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) +_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph) { const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr); _dl_process_cet_property_note (l, note, ph->p_memsz, ph->p_align); } static inline int __attribute__ ((always_inline)) -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz, - void *data) +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type, + uint32_t datasz, void *data) { return 0; } From patchwork Tue Nov 3 10:26:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 11876663 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=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 9BE03C2D0A3 for ; Tue, 3 Nov 2020 10:27:33 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 67C99206C0 for ; Tue, 3 Nov 2020 10:27:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="QXrFOriD"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="QXrFOriD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67C99206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-20324-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 15572 invoked by uid 550); 3 Nov 2020 10:27:24 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 15551 invoked from network); 3 Nov 2020 10:27:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b2LGHS8npIN3aGe1xT1kK15btQCbisIo7d+nrOmvXU0=; b=QXrFOriDF8wUheK7MPfvfeNpEH5ELxFAciGJK9mtZw877QqT1v4kBtmz/rIsCucC8BaXJLunnRK6eU90XShkRxr7hIeyreKnYWWO+ofdush/D+chVhPDHg7V7gnn5QuXWvxmZkjPctPhULOjq6n3aWMukjTu9CG0nJ0uKSMk3JQ= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.openwall.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.openwall.com; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: e0d9a8a02e872d3c X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FtiHxDxxfzlr3GOl7v7ohQxZsttt8jyMnW2iPZo+swkeyJLYuABDoPECRMJvMxx+b8D3VfhSi0VVAVHcpePw8ts/FARFieIdXAdyxXaK2BGFXaHr40DzyZn0/AT7MtOJ0yOM5c8Jx5sTwyB+ZfNJzORBnyWQCZIeN0tpfbbv/Dj873e8fSD4rwlUn7WvzL2t3DtJ9nmToXLWlZ2xxtXOYdvaXHTjInLXf7Tr+VgFqH61EMR7VAc+P+HAmtFCE2ewlrrH7WMIOi/XTEOely+TuVWxH5/0kE6KqUSAqRERaf+6Hl0DFbbvqi0PvVnPH1JO0DvmV6WggYs3dwv65MvIvw== 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=b2LGHS8npIN3aGe1xT1kK15btQCbisIo7d+nrOmvXU0=; b=JXLlGTTIQsLfRgj2xwkObOaTy3ON/PNARxRB1jdYLzxVJbpIsnUT0aRf5WGeZ7BKuqPg3i2I9WvDs+wVg3ZL/zpacIEct7RAJb8UuI/oBCJ8A7U4f6RmPqX8iyWt50Ml8TLNQjm1p/osQ4QcGQMaUrEK2V0UMcM2gwOjkpAXy3N2wQaLLsvxE/u4FJPS/09gyJP1Yy5IeuSR6CwYC1TO53qcSrfeKXNkgpNJNkmE911BtRX78JFDG6rjnUVl7IA8UiWC3X0THxWqVKNwx9akmgTAz9nFr7KBWclV/EY6ut1Ot0ygBTo1GoFzricQdfwVP2W2djNWKDKfjBV9dETc1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b2LGHS8npIN3aGe1xT1kK15btQCbisIo7d+nrOmvXU0=; b=QXrFOriDF8wUheK7MPfvfeNpEH5ELxFAciGJK9mtZw877QqT1v4kBtmz/rIsCucC8BaXJLunnRK6eU90XShkRxr7hIeyreKnYWWO+ofdush/D+chVhPDHg7V7gnn5QuXWvxmZkjPctPhULOjq6n3aWMukjTu9CG0nJ0uKSMk3JQ= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; From: Szabolcs Nagy To: libc-alpha@sourceware.org Cc: Jeremy Linton , Catalin Marinas , Mark Rutland , Will Deacon , Mark Brown , Florian Weimer , Kees Cook , Salvatore Mesoraca , Lennart Poettering , Topi Miettinen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com, linux-hardening@vger.kernel.org Subject: [PATCH 2/4] elf: Move note processing after l_phdr is updated [BZ #26831] Date: Tue, 3 Nov 2020 10:26:18 +0000 Message-Id: <7b008fd34f802456db3731a043ff56683b569ff7.1604393169.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO2P265CA0022.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::34) To PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 145055bf-8acc-4f82-451e-08d87fe30600 X-MS-TrafficTypeDiagnostic: PA4PR08MB6285:|AM9PR08MB6258: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: mlsiUh61bx5Crih3vA2Z4JW+a2wt3QsdhbSpnZqOyjqsM63KVmxW5XOr1X2TO3Dg1A9F/A/uNYels5NAdSLyJluaktIENrR8gRfaBbqFCjaXvg3Pr5iC9e1MFZzuDweG77qkYBvFpBgkhUuhUgmBaXdZVVG72PYO/tGE/mH+Ylhfe1YQcx1NTEsXSEGjFF5W65uAE3NjKpyWd2AY/T5lqqC+hdmimbYhOzU+uGgyPPFHS5MpKCl/vzUZ0TL1VGoR2vL2LZ+gu7viXGw9n3Dv1bx4tMYcrBFXB8lM92XEKjgA/g7mC2kQzxq4N7Swh6qgb3PwXYuRYp6ztJKEOlrv52Fke7/qLOZNWoPac2G0n1Gf34OgqdO8G6whwM1MgiDG X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PR3PR08MB5564.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(346002)(39860400002)(136003)(396003)(366004)(6506007)(36756003)(186003)(54906003)(478600001)(8936002)(6916009)(52116002)(316002)(4326008)(16526019)(26005)(69590400008)(86362001)(5660300002)(2616005)(44832011)(7416002)(956004)(8676002)(66476007)(66556008)(6512007)(83380400001)(6486002)(2906002)(6666004)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: m4/1TbY0scBRHWKeDmS23Ck/0jdSOWYCIpsJxujIy6Qhy5erw+FUqpuGY6k6Fqu8Z3r7jDCYMIhiJMlAZujBIULCskECo5/w5OxdqeHez9ZOFIrOWgJ1WcLJ4UxkK/8pHeE+HXr5xX4gJuoyOfhMNksHGc7kq2kENAuW+hThVJVx9HtsNa2V5MwT7m8I9JB03lS5o2ch7TM8TeYANislqEWiGxevhdEflqSTa7qqm9XgyjbFFMo29TZO/UG7cqoyXB08Q2nLLNqMIKdTyRQdpBAlyL1n1mCi3gxvXc1/cXmx8j5aBJHvFCuNrxAMqws4FAyHERpLdAXNtPwSGOAezm9WpTnuA0nawC/SWVR/fBLVt9BobCUCEK2wyqKDG5z0xbHWFcpLFOMfweXNoV3vkO1JCQHad2kbnmqTmFX03jyzKBC/2LK7X/EOuHXEk2zFoHWVPAxy99VHwM5i0j45YmA9m82ZdYmbxOLdWvlBtPa/SbuGJAiRhyxImq2X6bmkMHNjKG6O7m3Q/n0hMX5vsA/xIERm9cSk8gWUKQbaMhDEtn2Y9oBCzg0iqOWlyr9K3dDoAgG09PDcMG+uaMtq+wyGDP3FlBoj9DXHYvTRgFBTITKiyRAKR0lR7JoRnTYz7i//qDcF3Vt6153BFqUFcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6285 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a88b4fed-4a14-4294-4b4f-08d87fe2ea23 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DGARO5lzvxPWvFOdbyHu6F0Y5/SGPbQHd7Ius2ukGIwECp40e/zhHTRr90wPB1GemN4WtXQ6CnqSaQlkG57IWairMbwtzoG3eKBfBXIsu9PlunWS8GWq1YmN8rD2YGdOY1dlR/l/IYq5QSvunrSh6zBTmAvMzEyEjKWnizOKCt2BNw8pkYL8XF6T3ebaz9Z+i4ZDzRK11RC47vJJAa1aXAUrbl3MvE/Bz4pZXzhu5LN6UHRKTuUxh43JovZy3Gx/wArbdaBl8+mD59mRlnuKnYAYQfbiKYohWqhbWdOgt4kWAEdoxsgMdSghoI4W/n/bYWNzhBEyRDSAMNVNqAZcvHowed7xmsr22N8dfzjdLRgbftADfk/2UcJlpDAKnKMX647ojlJChvStWTY3PmvUxLzszmPitwRMXMBq+NIUkv0= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(346002)(136003)(376002)(396003)(39860400002)(46966005)(316002)(356005)(107886003)(6666004)(6512007)(8936002)(8676002)(47076004)(54906003)(81166007)(36756003)(36906005)(82740400003)(70206006)(70586007)(336012)(6486002)(69590400008)(478600001)(4326008)(2616005)(44832011)(83380400001)(34206002)(26005)(5660300002)(2906002)(186003)(956004)(16526019)(82310400003)(6506007)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 10:27:09.5755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 145055bf-8acc-4f82-451e-08d87fe30600 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6258 Program headers are processed in two pass: after the first pass load segments are mmapped so in the second pass target specific note processing logic can access the notes. The second pass is moved later so various link_map fields are set up that may be useful for note processing such as l_phdr. --- elf/dl-load.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index ceaab7f18e..673cf960a0 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1259,21 +1259,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, maplength, has_holes, loader); if (__glibc_unlikely (errstring != NULL)) goto call_lose; - - /* Process program headers again after load segments are mapped in - case processing requires accessing those segments. Scan program - headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY - exits. */ - for (ph = &phdr[l->l_phnum]; ph != phdr; --ph) - switch (ph[-1].p_type) - { - case PT_NOTE: - _dl_process_pt_note (l, fd, &ph[-1]); - break; - case PT_GNU_PROPERTY: - _dl_process_pt_gnu_property (l, fd, &ph[-1]); - break; - } } if (l->l_ld == 0) @@ -1481,6 +1466,21 @@ cannot enable executable stack as shared object requires"); /* Assign the next available module ID. */ l->l_tls_modid = _dl_next_tls_modid (); + /* Process program headers again after load segments are mapped in + case processing requires accessing those segments. Scan program + headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY + exits. */ + for (ph = &l->l_phdr[l->l_phnum]; ph != l->l_phdr; --ph) + switch (ph[-1].p_type) + { + case PT_NOTE: + _dl_process_pt_note (l, fd, &ph[-1]); + break; + case PT_GNU_PROPERTY: + _dl_process_pt_gnu_property (l, fd, &ph[-1]); + break; + } + #ifdef DL_AFTER_LOAD DL_AFTER_LOAD (l); #endif From patchwork Tue Nov 3 10:26:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 11876659 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=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 C094BC2D0A3 for ; Tue, 3 Nov 2020 10:27:53 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 52CEE206F1 for ; Tue, 3 Nov 2020 10:27:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="U+JRAS9d"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="U+JRAS9d" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52CEE206F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-20326-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 18064 invoked by uid 550); 3 Nov 2020 10:27:44 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 18044 invoked from network); 3 Nov 2020 10:27:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v+UNM3Lv5/vv+slUK/0uE5dl2sBpP1JzcBI5gH+FV0Y=; b=U+JRAS9dkHmx8i2SXzWRtugfJCWqyf5SOZZz7jSCM4rLJM2jksLVPauVzvlu6c2OeG1TBGTGfpxNHTub1ofTqN6qt2X/beNnHL5js6hmrqIovE6jqe0jEYlx2EvO5h26lxDlTIdskIsT3f+Wk+hoX4BNsGh8ZHcf+FNoIo9Kdms= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.openwall.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.openwall.com; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: a0ddbe5a41be8d3e X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fVZ71hYgIZjZfbwrp4bNq9AK8oPE/6SLJ+z086UwdxCOBKpUc5XUIIKGyTeN/kEg++bx2gH+ZTjnB8AqeqById0zX4cZBAM3wB0YwL0RVNMe6Gfk0PzACcrYmQ2GBvJKuoJ/12iglN4YSYouNYGQP4CpwrVd95L9a4Qk/Axz2ZlSSSxvZ3JeJqjgnhZOiizaFEy1x7yny9IFqzFLDALzhex0dRRHw3hxs53VB6Q4HJxwbV26O+HlIcyLlkBoUzoqv2AY/TTR229h6WzHBa2yEnQZai6gxbX+3FasWeVfv/abOTK3q1cXR2szH297wO/H/T247PfoBpATSn3KpylTZA== 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=v+UNM3Lv5/vv+slUK/0uE5dl2sBpP1JzcBI5gH+FV0Y=; b=KNk6/OCe3IQR8jqPiC6DnnRD9RPI+Q+6X57WOWuPTYPIDn0eVTJiJ2mmgVzDqPoE/KJuqKK3nMtnEt0XzZDnBex1kSGh7X0idjy8eNh7bEImbPTausoY5IrHh1/T43EpKPHVjbMaeIZaUNpYwrbHcrhnSZlJHnMPO3Ihw8cfSyID2GsUZ67iJPERNEnW5zFAtK5xP+cP1zHnIXjWCOxOJWRMLfBOIGD84i9FVVroTcojIavluSwVJDtqHtDwFsm+XnEfV6xD5ASTyQ3CHDJIl3x6dJzpp31hStSTTkQCPSnRicIOek2P+Xfn26bpR0abpBeeKVj4Ux6zgc6ZLqvecQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v+UNM3Lv5/vv+slUK/0uE5dl2sBpP1JzcBI5gH+FV0Y=; b=U+JRAS9dkHmx8i2SXzWRtugfJCWqyf5SOZZz7jSCM4rLJM2jksLVPauVzvlu6c2OeG1TBGTGfpxNHTub1ofTqN6qt2X/beNnHL5js6hmrqIovE6jqe0jEYlx2EvO5h26lxDlTIdskIsT3f+Wk+hoX4BNsGh8ZHcf+FNoIo9Kdms= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; From: Szabolcs Nagy To: libc-alpha@sourceware.org Cc: Jeremy Linton , Catalin Marinas , Mark Rutland , Will Deacon , Mark Brown , Florian Weimer , Kees Cook , Salvatore Mesoraca , Lennart Poettering , Topi Miettinen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com, linux-hardening@vger.kernel.org Subject: [PATCH 3/4] aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831] Date: Tue, 3 Nov 2020 10:26:29 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO2P265CA0215.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9e::35) To PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7e91bcb8-a868-4822-882a-08d87fe311f9 X-MS-TrafficTypeDiagnostic: PA4PR08MB6223:|AM0PR08MB5411: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3826;OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: pFJzWG8Yw5e/GUYk3D/pVFVvWPOjiV6M9uIjJphRlHnGQsHOn+hoZ3lsdtBSnnEOZn6nzma3/gtL/Wuh4ePIs0zTVYWKqRRMHASmjNHe2bw+DgY8UMa67sZ3XcvVwKBgwJ9wG3Y4DeBO+ptvj2aAml4LqAFvNKOgdi9EEkq6/F1nOe87MLSLk124ih2ufbVpqYsyVolpKsaaEbXxxxWI4TZJBXRj3bS+M0nzfXm4O6Enxsc4Pf5HH0LFx8jap5gGHsJ83AIlu55M9hXgpZnfPn1uOsGj133zcyJ7tXhILSlk0KslmUQ/0AGemmVAmWh4p/HINnqrzheu35ks3ltz5fAkECWnn46EwORlqchOfrL+WjFjNKKRso8ta5jhra/2 X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PR3PR08MB5564.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(396003)(376002)(346002)(136003)(366004)(5660300002)(2906002)(66556008)(6506007)(8676002)(66946007)(478600001)(54906003)(66476007)(6666004)(6486002)(4326008)(6916009)(6512007)(69590400008)(186003)(16526019)(2616005)(7416002)(36756003)(956004)(8936002)(86362001)(44832011)(83380400001)(52116002)(316002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hDNYcEUHdOkCPtFy9z0Y2Fh3enuTGFcmEu04hq0ufK3iZbr6P8OO8W+GP0Y8X3C4AFsLoSg36mosfLULF2RAVNZdvrjzyXWjP3m6ib6Id1HwrefhRCbvEeRh/XTfRAVtgv0Jk9cApl56ktRou/zIUDBWkMBLBd/lUc7WaSlfrkXiL7SyOPiGveqVcNfygaGp+7UZP1ONGX5YPwZIOCB5piaTKceGDN4E3gdOmeq5StH6PxZhLVxN1GSr7ANTnLuSubLU109DsXmfgCHiyDd8awvL9xnY4w86/sWaAT1yjLHFB02kkWnZjjWTcPu+X6tVO+vzt88rCc3jh3lFQHaExjsnm8U+j1+RutF260PvPYGVs6f2UJVKW9KeYh+vU6zQOmDxxPkn4JeIHCY22PXLRaGdiuW51fv2KiW/SiJb2nz+4ye/vEeTMGvY4G58Zjo5J0q6qKK+jESJcJba8edbH8oFD2VTT5XMaZ9i7M12TBJ9MsTJ/gDL6LT8V5rEDg15Hr1HbQBkd++OG5E+gdwxIR4s7iS1LcxShHALONAla/NsnpWJt2mJjMYT49Lgctjm2d9iaVjlya3L2ElQ/sWqOh6xKK7Sc7XB0OOTzIOtlvsjeCEphsIzTFjE71Olm44W+yQzxm38E1F5t6Dg1aKqKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6223 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: facf50f2-b8a2-48ba-8cb6-08d87fe2f13c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eBHdbtMG6z0PqvCMoageu1MEV+llMJ+lLaerlEM99gVpvC/vON/EQyUZrMShd8ZDxqC6nh+wONJjRch2Ksd2XA/boraxxkz7u8Pq3vUKwB6TZmAQA3eRLY+VHVYsslk/WPhu/ozYHDRk+1vZv3ulLc5PEDZZ/obPxi4VmfJNswdmwhois7yJankA6AwDPEkIi1r+W5quYW9FlvKxG/GzXnHDRlYB75XctGsJDKUKSxK5wEXJFHeiN/aw2qNCAzoWBhbVXLzcV3DLO7tULnNdPuO3AJQI0xW6C3Fjutorx0TtWPEcBIyh43WlEsUWT10/07jue8rIS3XLz05dArcanV7VMrs6NH6LpGhHygT8NwuCHdXLEX8JonJCkEsil0InNEpfWgF1aouAXARkktggnqNjuXIp1YsLXq0YdxSiOBO+QpkBW7TwqTRB644J4kLT X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(136003)(39860400002)(376002)(396003)(346002)(46966005)(8936002)(36906005)(8676002)(956004)(316002)(69590400008)(82310400003)(2616005)(2906002)(83380400001)(86362001)(107886003)(6666004)(34206002)(336012)(4326008)(6512007)(36756003)(70206006)(6506007)(44832011)(478600001)(26005)(70586007)(16526019)(186003)(82740400003)(54906003)(47076004)(5660300002)(6486002)(81166007)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 10:27:29.7280 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e91bcb8-a868-4822-882a-08d87fe311f9 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5411 Re-mmap executable segments if possible instead of using mprotect to add PROT_BTI. This allows using BTI protection with security policies that prevent mprotect with PROT_EXEC. If the fd of the ELF module is not available because it was kernel mapped then mprotect is used and failures are ignored. It is expected that linux kernel will add PROT_BTI when mapping a module (current linux as of version 5.9 does not do this). Computing the mapping parameters follows the logic of _dl_map_object_from_fd more closely now. Fixes bug 26831. --- sysdeps/aarch64/dl-bti.c | 46 ++++++++++++++++++++------------------- sysdeps/aarch64/dl-prop.h | 14 +++++++----- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/sysdeps/aarch64/dl-bti.c b/sysdeps/aarch64/dl-bti.c index 196e462520..385f1731ca 100644 --- a/sysdeps/aarch64/dl-bti.c +++ b/sysdeps/aarch64/dl-bti.c @@ -19,43 +19,45 @@ #include #include #include +#include /* For MAP_COPY. */ -static int -enable_bti (struct link_map *map, const char *program) +/* Enable BTI protection for MAP. */ + +void +_dl_bti_protect (struct link_map *map, int fd) { + const size_t pagesz = GLRO(dl_pagesize); const ElfW(Phdr) *phdr; - unsigned prot; for (phdr = map->l_phdr; phdr < &map->l_phdr[map->l_phnum]; ++phdr) if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X)) { - void *start = (void *) (phdr->p_vaddr + map->l_addr); - size_t len = phdr->p_memsz; - - prot = PROT_EXEC | PROT_BTI; + size_t vstart = ALIGN_DOWN (phdr->p_vaddr, pagesz); + size_t vend = ALIGN_UP (phdr->p_vaddr + phdr->p_filesz, pagesz); + off_t off = ALIGN_DOWN (phdr->p_offset, pagesz); + void *start = (void *) (vstart + map->l_addr); + size_t len = vend - vstart; + + /* Add PROT_BTI. */ + unsigned prot = PROT_EXEC | PROT_BTI; if (phdr->p_flags & PF_R) prot |= PROT_READ; if (phdr->p_flags & PF_W) prot |= PROT_WRITE; - if (__mprotect (start, len, prot) < 0) + if (fd == -1) + { + /* Ignore failures: rely on the kernel adding PROT_BTI then. */ + __mprotect (start, len, prot); + } + else { - if (program) - _dl_fatal_printf ("%s: mprotect failed to turn on BTI\n", - map->l_name); - else + void *p = __mmap (start, len, prot, MAP_FIXED|MAP_COPY|MAP_FILE, + fd, off); + if (p == MAP_FAILED) _dl_signal_error (errno, map->l_name, "dlopen", - N_("mprotect failed to turn on BTI")); + N_("failed to turn on BTI protection")); } } return 0; } - -/* Enable BTI for L if required. */ - -void -_dl_bti_check (struct link_map *l, const char *program) -{ - if (GLRO(dl_aarch64_cpu_features).bti && l->l_mach.bti) - enable_bti (l, program); -} diff --git a/sysdeps/aarch64/dl-prop.h b/sysdeps/aarch64/dl-prop.h index 2016d1472e..762bc93733 100644 --- a/sysdeps/aarch64/dl-prop.h +++ b/sysdeps/aarch64/dl-prop.h @@ -19,19 +19,16 @@ #ifndef _DL_PROP_H #define _DL_PROP_H -extern void _dl_bti_check (struct link_map *, const char *) - attribute_hidden; +extern void _dl_bti_protect (struct link_map *, int) attribute_hidden; static inline void __attribute__ ((always_inline)) _rtld_main_check (struct link_map *m, const char *program) { - _dl_bti_check (m, program); } static inline void __attribute__ ((always_inline)) _dl_open_check (struct link_map *m) { - _dl_bti_check (m, NULL); } static inline void __attribute__ ((always_inline)) @@ -43,6 +40,10 @@ static inline int _dl_process_gnu_property (struct link_map *l, int fd, uint32_t type, uint32_t datasz, void *data) { + if (!GLRO(dl_aarch64_cpu_features).bti) + /* Skip note processing. */ + return 0; + if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) { /* Stop if the property note is ill-formed. */ @@ -51,7 +52,10 @@ _dl_process_gnu_property (struct link_map *l, int fd, uint32_t type, unsigned int feature_1 = *(unsigned int *) data; if (feature_1 & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) - l->l_mach.bti = true; + { + l->l_mach.bti = true; /* No longer needed. */ + _dl_bti_protect (l, fd); + } /* Stop if we processed the property note. */ return 0; From patchwork Tue Nov 3 10:26:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 11876661 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=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 41BD3C2D0A3 for ; Tue, 3 Nov 2020 10:27:41 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 1BC53206C0 for ; Tue, 3 Nov 2020 10:27:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="Cr4LTSGY"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="Cr4LTSGY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BC53206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-20325-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 15596 invoked by uid 550); 3 Nov 2020 10:27:25 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 15571 invoked from network); 3 Nov 2020 10:27:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Wlxmz1lsQy9ANT5hBuxauGpsVdR7Lp8VNGTXKRA7KP8=; b=Cr4LTSGYEETkHIILW5Sr0QH0FPLv/LPR1ukjESdzD5t7gHd815xjEsPcBP1rl1lPzcunwfqWkDWKHBpN9JGdA+xGKvhvGmpIz6BiLQGlbYZT6+I0jzzb4f0Kcx4dJ/0HXhRWboOU3qI4QcrwKnzcKWLl92RmPOO5TIW9GnB060A= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.openwall.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.openwall.com; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 3d316982cdffdc9e X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T+UluvmSqw4nvycpam5RjdCFYFsWnhttU1aWyDR7YtfUC7HvgSDVDc7KsVhPveRHmZGuFOunqfBaalbjFaVTN9y91W9ADcl15l7Ez5UgNNrlQBGmEK16yEEkSBBW1wEvluOlk3lE7o/Baht6jG83UJDiiA3Od/bHxiHInIvpzRTd5O14EiP+qiweYl/ZMtg5KULe/J3W+7JNG1+w57kiy8YElIyOc3kC65thAdRLEZbS+IVQU+gVEJBKLeWBVm/SSNV39wQVDDPZrADO9/Gcjk/NL7ajxVPo1E1VhCWYGbDs15oVubLd9guZSOyfsG0dRoIEllNFm3NakMXKUylcoA== 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=Wlxmz1lsQy9ANT5hBuxauGpsVdR7Lp8VNGTXKRA7KP8=; b=D6HbCd256X55B4SAy/+AeuY/bnjKLxmHM9Mpk5Kg/QA3VrlyyrStzVzjGHwZncP8/LFDH6AzC7nd4O1hRTRh0aqrHpk4I9OmmdYG9zm54EAIecZvcClJ2XRNrt72YjC/KdvNq9ZFhFl2G/3aICnkdfe8KOReJxgukY5wuzVVLHPhA8TNXPk1YXKzoQMf4MRxaBsweqCIlbd3ZdYSzaThb+oSqz6cgwCWYcu3NsNt3GdHQ2Dq4RS99266j57e1wdZ03tuletzOrA8Vsjug+EOvrpiDqjE89tAVvix2T9kUCL+rOEcBlazWup01oj0CC8+5IVvgb1ZzoxEv5E9/EFJqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Wlxmz1lsQy9ANT5hBuxauGpsVdR7Lp8VNGTXKRA7KP8=; b=Cr4LTSGYEETkHIILW5Sr0QH0FPLv/LPR1ukjESdzD5t7gHd815xjEsPcBP1rl1lPzcunwfqWkDWKHBpN9JGdA+xGKvhvGmpIz6BiLQGlbYZT6+I0jzzb4f0Kcx4dJ/0HXhRWboOU3qI4QcrwKnzcKWLl92RmPOO5TIW9GnB060A= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; From: Szabolcs Nagy To: libc-alpha@sourceware.org Cc: Jeremy Linton , Catalin Marinas , Mark Rutland , Will Deacon , Mark Brown , Florian Weimer , Kees Cook , Salvatore Mesoraca , Lennart Poettering , Topi Miettinen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com, linux-hardening@vger.kernel.org Subject: [PATCH 4/4] aarch64: Remove the bti link_map field [BZ #26831] Date: Tue, 3 Nov 2020 10:26:42 +0000 Message-Id: <4dadd9c101e32b17e927d56966c54e734ced21ab.1604393169.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO2P123CA0020.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:a6::32) To PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a26491d6-f082-4988-4b2d-08d87fe30656 X-MS-TrafficTypeDiagnostic: PA4PR08MB6223:|DBBPR08MB4233: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: GpX+9AZXL1rA7ftikTwlnVdsxsZ8r8ULLNyUhbJEF3b+g59pp2w1vUpuOQtaix5PB+Oe8OfQUlE+5t9cNv30edS+6vcbzyEkT3/s1n53GjV9n8I6pDyhJapu4YbJR0jyAhwIIJrEKa2FtZVczls7DlzvGEBJSswUiBulAwkw6akKhuy23qG2cPSZ1U1kWVML45l0aTvvyVPy3f2W+S7R5806A+X8nIdGtI3VSRjSip9N+EY1Z80NuKyhJSbzysn7BtONSOROKqSsdJd327BVL6YSBbllWAwVwTU8pqW6lB4hwRbYcegOfpElwQBmSTk1SkbafKYiZh71YPXwe/GTCBAvvnZPPRtXDnTMcG+9aJDFHGwYf2VIqtYpsnOk0Zti X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PR3PR08MB5564.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(396003)(376002)(346002)(136003)(366004)(5660300002)(2906002)(66556008)(6506007)(8676002)(66946007)(478600001)(54906003)(66476007)(6666004)(6486002)(4326008)(6916009)(6512007)(69590400008)(186003)(16526019)(2616005)(7416002)(36756003)(956004)(8936002)(86362001)(44832011)(83380400001)(52116002)(316002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: n+W63gGQDmjlTcHyctXjrchkrxCzFfRzkiydbGMpSLw2hRtMFazdpMP+Iy1+FQCGS21ZilzkcazqPBPKGXKR49RXI5GINqtDQYt1a7KHj5l7KAbJXHJMg6oBmidHtY8iTzEMrtBcxl95NPXJXgxhSbE2ON750mZ5mAPUiSsx8Bt/bzx2YnTnJAlNA0jtEZ6bXxcbNqXR8xdUJZGq/KxhKmzgSGORBApYDfzo22MjKU9ALwJC/UbKyYmR4Nw9cvXX06J2hDN3pKkqhjRaK8RDo/xemX0WVQJdQYU7VTJnUgfy/9mMpNk9gqEOrnbtgLlgSTzEU2IYgz6ZJbt3+cnK7H6F1TeLOcjvHZxgDbKtMwspq802M9fpu2R9hFCCamPuI/Vu+2uiqhokO1U7s9lj1Pk7pan8jS7v2FdonkNTrdsfDV644owsD00mDbG8db/rGHPjY+0DVUFHJsd52bvrRIgYhN2VO3EWhQ97sj2aYLYItX5d15gLjHLtSuSNRoZH8e1rU8cNWQIgNligY3hLe7tpRgBgrJixAmkxXNPXUmVkp9khH6FjCvmRg8C1ET+Ekp1T2mcu7JD+JryWeyZB0sVHKbwOW0H/ziOwXiRtXOwrxNzZhgpWsZnT8XrX2EpCx9hNFTTrhWKno/Iuz0F/OQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6223 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: b2e1cbd6-8844-4c3d-f2f3-08d87fe2f874 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g5mNCvuvhbEaGRvt2uBP6HauCqAxusdfjLugnPEor06KdRsbUolB9FZh04Bzjq/PgVOUt3EQYQfl6jqnQcwzIyeAsFZTBKdrvuTIQpUSKWrxcBmHHNW4iMLsdGlM9m2WSFrVlWMnqWkBJEevBygYJJ+9rkVG1aQW8ezGPvetdPN0Q/Y0gsOqIVozN4ZB+OrkdeU73TezovCRXo8IOJrjqQqULTvOYPDdY0+aA20MkBBZSOPjm0WaVUV0jLHyGW+7lOX1NIYQERS+D5+1SIcHxetu+ydlLcyudixSV0W1e2PVUPdvzR4wguGpbFIx93DHSMtaFPikIkRtmwiNyKMkHxiGQfTAPvWP48JSnULEnZ6fhh+cunVLQc7S4DuL3QDbtpSmZsoQWNHOQndLU3av3OAqfDh41OL8YMQza9x4qej8sFuA977nk+lH7Dqjm7sz X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(346002)(376002)(136003)(396003)(39860400002)(46966005)(81166007)(26005)(47076004)(6666004)(956004)(2616005)(6486002)(54906003)(36756003)(186003)(6506007)(16526019)(2906002)(83380400001)(478600001)(8676002)(356005)(70206006)(4326008)(336012)(82310400003)(5660300002)(316002)(34206002)(70586007)(44832011)(86362001)(82740400003)(8936002)(69590400008)(107886003)(6512007);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 10:27:11.3472 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a26491d6-f082-4988-4b2d-08d87fe30656 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4233 The bti link_map field is no longer necessary because PROT_BTI is applied at note processing time immediately instead of in _dl_open_check based on the bti field. This is a separate patch that is not expected to be backported to avoid changing the link_map layout that is libc internal ABI. --- sysdeps/aarch64/dl-prop.h | 5 +---- sysdeps/aarch64/linkmap.h | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/sysdeps/aarch64/dl-prop.h b/sysdeps/aarch64/dl-prop.h index 762bc93733..cf14381e4a 100644 --- a/sysdeps/aarch64/dl-prop.h +++ b/sysdeps/aarch64/dl-prop.h @@ -52,10 +52,7 @@ _dl_process_gnu_property (struct link_map *l, int fd, uint32_t type, unsigned int feature_1 = *(unsigned int *) data; if (feature_1 & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) - { - l->l_mach.bti = true; /* No longer needed. */ - _dl_bti_protect (l, fd); - } + _dl_bti_protect (l, fd); /* Stop if we processed the property note. */ return 0; diff --git a/sysdeps/aarch64/linkmap.h b/sysdeps/aarch64/linkmap.h index 847a03ace2..e921e77495 100644 --- a/sysdeps/aarch64/linkmap.h +++ b/sysdeps/aarch64/linkmap.h @@ -22,5 +22,4 @@ struct link_map_machine { ElfW(Addr) plt; /* Address of .plt */ void *tlsdesc_table; /* Address of TLS descriptor hash table. */ - bool bti; /* Branch Target Identification is enabled. */ };