From patchwork Mon Jun 22 13:59:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39717 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8AAA8388A80E; Mon, 22 Jun 2020 13:59:32 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130082.outbound.protection.outlook.com [40.107.13.82]) by sourceware.org (Postfix) with ESMTPS id 93DA73887013 for ; Mon, 22 Jun 2020 13:59:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 93DA73887013 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=BHLx/io0FZJ2YurE5O/DL90hJy3tVlAxqhrNlqVW1HA=; b=u3g4PCpavs0rL5EbJxRq9tBGFC4bXk4Rpp/vM602xxe+EUM4wVpyvIRVfG3Eaos3A5lj2E+M1daDClG3g0FWfhWqa2OLP1yuhoV9IyWOxGiO4ng7rmkyMcnO2KGRFYvhGoHpDsPb+HpkmPTEziaKwb4WBME81ktuzJpw+6tOl3U= Received: from AM6PR0502CA0038.eurprd05.prod.outlook.com (2603:10a6:20b:56::15) by DB7PR08MB3209.eurprd08.prod.outlook.com (2603:10a6:5:1e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Mon, 22 Jun 2020 13:59:28 +0000 Received: from AM5EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:56:cafe::c7) by AM6PR0502CA0038.outlook.office365.com (2603:10a6:20b:56::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT033.mail.protection.outlook.com (10.152.16.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:27 +0000 Received: ("Tessian outbound 2ba684f51d22:v59"); Mon, 22 Jun 2020 13:59:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d5d16bb5af3205b9 X-CR-MTA-TID: 64aa7808 Received: from 17e2f8673d14.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 18E7CDB9-FDB0-4B0B-9544-7E484408F469.1; Mon, 22 Jun 2020 13:59:22 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 17e2f8673d14.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 13:59:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CvONO++dCII7yTD/6XTl5NyebY2K4+lzvYABDmWJc89g7r3G+PhuyjGYFAtRXam4F8eurfH86VQpRSCUGZ4mOq6emgNLN/ppaomHCzytPONFhxIgv8joj1ncLxvmwEPRGd8qT46HKnJ8aUZ2HZ3EixwO7ZIm2GyWu5aMSZLKX+FBgfUZuG3+IiUXy2rxmwIBkNahjHsgOpcrySt+1avxQ3MzjNa+sOsbEjPdYq13PG//dC6bi+h5bYwRMaSxG43KYN6BCVSDLJmMG3csxjmVA2hB9DygUZa6zAwtqelu6mW+vVyYYO1XPH0m9HyxxySRm9+XtY6LB6Y78/5tnJcv6A== 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=BHLx/io0FZJ2YurE5O/DL90hJy3tVlAxqhrNlqVW1HA=; b=ZlCSRoRAfbwUAQuxZfxV9dfnvhL9zWgmPV5Y+mqgigT9JHA4RnHdVykP9DqB+GTc3YZtUvOTHFvGfsygBcZPYsxDVu6c77UpP9zW9uPf65zFD6y7jZoj0BwyH68RspI9E3fKzhaNuNLSfY/txM7ayetHSMJ2pviar94p0elLGIrJgvp5xiBcpT40zatbMDTivb8FjMhXZeNRjsmKu4x5u4C6PI3CWtjZsgqKwIL0HYmJKdMF58cNZ3To3jwmhTosohs9pO4Vi4h25XDGG1gOFoFtOzf1QMAoOU0jEJIGZlvhfglsBX27cqjsX59H2fZWe6kn1vPOG+TzyuFaua1vfw== 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=BHLx/io0FZJ2YurE5O/DL90hJy3tVlAxqhrNlqVW1HA=; b=u3g4PCpavs0rL5EbJxRq9tBGFC4bXk4Rpp/vM602xxe+EUM4wVpyvIRVfG3Eaos3A5lj2E+M1daDClG3g0FWfhWqa2OLP1yuhoV9IyWOxGiO4ng7rmkyMcnO2KGRFYvhGoHpDsPb+HpkmPTEziaKwb4WBME81ktuzJpw+6tOl3U= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4344.eurprd08.prod.outlook.com (2603:10a6:20b:74::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 13:59:21 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 13:59:21 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 01/14] Rewrite abi-note.S in C. Date: Mon, 22 Jun 2020 14:59:15 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0126.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::18) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LO2P265CA0126.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:20 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bcef9ef9-c5ab-467b-3da8-08d816b47a96 X-MS-TrafficTypeDiagnostic: AM6PR08MB4344:|DB7PR08MB3209: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ixVsvziL1LTCdJD5GJ22K92mvLFjcQ2Ho84n0G2+yHnzkiBc5JOJyY30Y3W4+5NqeAjunogVYssMXBOZWM9AWjeRv7YROKeNm0KoIk95eynIe3DexPau/JrBB/fliEti8iX4vmVB6Wt1PFD1jlymE3OiK3jmlkDs/ykvayb7dr1mbhykyB1WbZ4ZnDNnvmCCybCEUBDz8tTy5ifZyQ7mZHJSOYUz/HXT2f5A8h2HFX9djyziyHmFnUjKaKLHM7HceB8GMmyMxkyR2OtqtBUY88L/M0MmNUCLHL9n0mCTTUaXDi8VSupvUM3lLE3zmGe9MnP+7IfAz6HWlKugKqhU6ndkKMiVI+Y/2QJaLWVKUeCM+lXp79Wl4XhWhpil/vbiUnwsQMeBL2x4YyiD3XU2o/qZJPmSCfJ/21uMVnAu/vA= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(396003)(346002)(366004)(376002)(52116002)(2616005)(69590400007)(66946007)(66556008)(26005)(66476007)(6916009)(956004)(6666004)(6506007)(2906002)(186003)(16526019)(86362001)(6486002)(44832011)(478600001)(8936002)(36756003)(316002)(5660300002)(83380400001)(6512007)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: V0vxqX+khblzd4fSmDOso6O3vQCLwddiqZrHeVxXos3HO8UFyIleMVPtQL6le/eS/j0LtmoSKb6DOdp5zS1uTIRYuZtXXrZDQhQp/WPEk6BShqB40Ay5ItYfsPUj9SnvUyZW8d9t2T0GmFyHF+r7YdlvUBZiu8o52L5Cwk0d+z2/J+uELn2CsxnYS3HxJi+eO1SNbiFUUd7V++O6nILU0E+K3UQU+xzrniy6fPxMXC95SI+qYkO61GZVejEcDVut1yKeQpX7Kvpat1kPWkqe20XMaY/0tta9cJJX5odLyxICSKCuNBav/zCTtKNesStmWsB8/vOVO74pfctTsB6ayGTZMpbdmx5cqmbYMgdJNBjct+kARIkuSco49yWRuJcwYQMpwO4Lhv3/+WFD7qXoug0PJPWXs5CC9utSB5wVPOL53r4GvtT5O1vIsnEswQC2TuB3dFCyXJYRkYV+sGuQMMYkMRfjLOULsXOgAKKKYUU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4344 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: AM5EUR03FT033.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(346002)(376002)(136003)(39860400002)(396003)(46966005)(70586007)(956004)(336012)(8676002)(70206006)(2616005)(6512007)(82310400002)(6506007)(47076004)(82740400003)(69590400007)(81166007)(83380400001)(86362001)(36756003)(356005)(44832011)(6486002)(478600001)(6666004)(6916009)(26005)(16526019)(36906005)(316002)(5660300002)(2906002)(8936002)(186003)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 71b8f26f-6baf-4c3e-bfe8-08d816b4764c X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0I059I9NxgKeZsXPUiefuTIXDyVtrWxcILtQ+xQK09HvNSAiDoldYZfMLstWU6RaY8IIWsXVDd4V+2zP9qXWgz5o8dH6QzGfPgQZ/02ywAlORNTcSxyQapyOjwLek3a1OImuCrKbfPGvagcpbe7WNaJgLU/3edccgRxg/ZBJaHyfuHH8n6AvWuoX5/5GfJn2ofXNy+9kibf9P6d3ApEH4FQJ4jdTc+Sn6fBWxfhZ4oV9WjTf018qRpNYayHZlxV7LlWo5gREIpk4WGJCmju2FeCA4bcFNhkI+KNiArN7WvztRYrpJDn1r8eudzL1G8X9jwtl/nEfXH3qwNy2/DHpiSOu1ALqaoq0Ev+jocihv8aDo/v1iBiUgj6yNeOJjNMhUGgwzLmnqlveoV+kI+L2HpDza6zVbfJSFXHEhyd26Y90WdmSFqmocnafj1zv08iCx1udgkjPKtK+Pcka7z1opw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 13:59:27.8727 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bcef9ef9-c5ab-467b-3da8-08d816b47a96 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3209 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Using C code allows the compiler to add target specific object file markings based on CFLAGS. The arm specific abi-note.S is removed and similar object file fix up will be avoided on AArch64 with standard branch-prtection. --- csu/{abi-note.S => abi-note.c} | 23 +++++++++++++---------- sysdeps/arm/abi-note.S | 8 -------- 2 files changed, 13 insertions(+), 18 deletions(-) rename csu/{abi-note.S => abi-note.c} (90%) delete mode 100644 sysdeps/arm/abi-note.S diff --git a/csu/abi-note.S b/csu/abi-note.c similarity index 90% rename from csu/abi-note.S rename to csu/abi-note.c index 2b4b5f8824..db195c7ab7 100644 --- a/csu/abi-note.S +++ b/csu/abi-note.c @@ -53,6 +53,8 @@ offset length contents identify the earliest release of that OS that supports this ABI. See abi-tags (top level) for details. */ +#include +#include #include #include /* OS-specific ABI tag value */ @@ -60,13 +62,14 @@ offset length contents name begins with `.note' and creates a PT_NOTE program header entry pointing at it. */ - .section ".note.ABI-tag", "a" - .p2align 2 - .long 1f - 0f /* name length */ - .long 3f - 2f /* data length */ - .long 1 /* note type */ -0: .asciz "GNU" /* vendor name */ -1: .p2align 2 -2: .long __ABI_TAG_OS /* note data: the ABI tag */ - .long __ABI_TAG_VERSION -3: .p2align 2 /* pad out section */ +__attribute__ ((used, aligned (4), section (".note.ABI-tag"))) +static const struct +{ + ElfW(Nhdr) nhdr; + char name[4]; + int32_t desc[4]; +} __abi_tag = { + { .n_namesz = 4, .n_descsz = 16, .n_type = 1 }, + "GNU", + { __ABI_TAG_OS, __ABI_TAG_VERSION } +}; diff --git a/sysdeps/arm/abi-note.S b/sysdeps/arm/abi-note.S deleted file mode 100644 index 07bd4c4619..0000000000 --- a/sysdeps/arm/abi-note.S +++ /dev/null @@ -1,8 +0,0 @@ -/* Tag_ABI_align8_preserved: This code preserves 8-byte - alignment in any callee. */ - .eabi_attribute 25, 1 -/* Tag_ABI_align8_needed: This code may require 8-byte alignment from - the caller. */ - .eabi_attribute 24, 1 - -#include From patchwork Mon Jun 22 13:59:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39718 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6096D388A810; Mon, 22 Jun 2020 13:59:41 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80075.outbound.protection.outlook.com [40.107.8.75]) by sourceware.org (Postfix) with ESMTPS id C916A3887013 for ; Mon, 22 Jun 2020 13:59:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C916A3887013 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=fEi7LUYSbc6kJcZwWclKwetJ3pn75Ey8g9x1dXZ8Ak8=; b=4EbXqF8HaDyISVTj9gvQdmqY8hS6m+gquJBEFuyWUw6/fIS/kqGxx51POxNoHjvnM5zsT9e/6+ZowMTb3eow+0qBUuhxbMNSry1z0F202akSjq9V2U9QhFCpSLnWUwNdjadWEt94b4ttIHY9O98hYHnKLu/1N1C5Fvuo+pPi/X0= Received: from AM5PR0201CA0022.eurprd02.prod.outlook.com (2603:10a6:203:3d::32) by AM6PR08MB3301.eurprd08.prod.outlook.com (2603:10a6:209:47::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 13:59:37 +0000 Received: from VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:3d:cafe::3f) by AM5PR0201CA0022.outlook.office365.com (2603:10a6:203:3d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT004.mail.protection.outlook.com (10.152.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:36 +0000 Received: ("Tessian outbound da41658aa5d4:v59"); Mon, 22 Jun 2020 13:59:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: af4f880c2bf0ff57 X-CR-MTA-TID: 64aa7808 Received: from c30830c61212.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 472C1102-077E-4F94-B3D5-F25375442035.1; Mon, 22 Jun 2020 13:59:31 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c30830c61212.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 13:59:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZZGFcGRWLSZOn9GhPsmQ57ZMyLt4IGC8YA4BZaEkuFRirE8h4LnpAX39/cRaoHhXa0GFXcn8PqqUYMmgkydKnheyN5cUKH6nCrFRFCLibW295+t0nKGda9nZY/Bra/JKPynCQfgXmQ2V4zY0qveC+1OVA339TAxvbyVrQ7uofIDMjo8ulUCuEMg9U13dFfgcxqc9e02hEVeGKFQzmaQ81c+8urlfmX4BYMAXJXwr3q2Ne4zq23YRk2RCaL0wrQ59x1Ddqxq7FA3wPXPdLgr1I0bQ6eoL4B6uR5jDHqf6T4S1uBG0Rsn3Lk8HAAMS7wEmihUvBxhTj8AlDRuk0/uJ+w== 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=fEi7LUYSbc6kJcZwWclKwetJ3pn75Ey8g9x1dXZ8Ak8=; b=bFV1sdb8MkLizExVpR+b3pWlIeh2zvYnA35zR6AkBbJcHqHRwE3qfcF3duPt5p8en15yuh3y39fycX0K8gqZb1PWmJLrlEHS+4Y6q51if+3n80Dm8tX9aGTwEjK4gE+ozTLhTTwXJtg9im73l7iGPX7A/yT6En4KoEoTri8vW+mv7Y3tqQSg9l5c3oJLxUnDbQDgw2NrXMIxkeAM+9+9+n2ixtXjSReav9djCh47Vvmxy0S1TyVY5OZjHcpDsfpBr0aTGr+1Z49lYpIe7gqbIbtm+IMUsOqK2gX9iGMi86BGhqtKmSxwawSBG7fINRj+vJLJx5g2kbMje+/cTBn9+g== 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=fEi7LUYSbc6kJcZwWclKwetJ3pn75Ey8g9x1dXZ8Ak8=; b=4EbXqF8HaDyISVTj9gvQdmqY8hS6m+gquJBEFuyWUw6/fIS/kqGxx51POxNoHjvnM5zsT9e/6+ZowMTb3eow+0qBUuhxbMNSry1z0F202akSjq9V2U9QhFCpSLnWUwNdjadWEt94b4ttIHY9O98hYHnKLu/1N1C5Fvuo+pPi/X0= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 13:59:30 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 13:59:30 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 02/14] aarch64: configure test for BTI support Date: Mon, 22 Jun 2020 14:59:23 +0100 Message-Id: <088a606441f624221ce9be2038b71ca908f40c42.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0158.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::26) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LO2P265CA0158.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:29 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6a0825b9-206f-4f80-6e21-08d816b47fe6 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|AM6PR08MB3301: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xpmTGjQBR/gMv40OL8PgR9mporvCCgCXohNGHFifI6mI93H/olb0+A0f+PDKYF34Ymp3Y7V5gCKWnP8rWGFl7dbAQiVpIDSNAB6DwCpB/C8eztpAHKCd7Mu2/sZNWMXLOvm5/gUUH0uTDoYvMDOLDMKpIOCFfnsj3Cutom06uHOO01+J0kCTbtL+E7wRu2UXzCZaLRmu887RlhWmN9Wj8BjkPDLB5fPPzaoix47Rj5YIzfwFaSwbn4zBgdvvBiYFkwja/Ymz5LJqT/D604dIOvL48qeaYf8T2hitYZRAm1dIf0e6OQWWz0LTlhhPPqddXNScR1z8V6AGhDzCP0f4k2SFM42K7Q/rd1YK1x9nvGhhhY+AaWntXk1W3V94DC+9C7GKUheg8YHRICSaTgXEMoeqFbqQa1liyvZRtz3C2b8= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(86362001)(6916009)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 32KHkzio7kgoRWCz+FUPytCAIC5symAq9PGYk4PsApSRRvHhdk5KtOqGfjUl+uWsIDMP2YIMv8ZsnvLuM4IloNBVJcLD+GxR2y+XXdpPV1a35SrJDr0MPpuXlCgdIGM1R2abOeC+wce4NZ4qA/y/+8e5IhE4for3c1MdSLh0n8KiO5bMvWT4rrMapJLw4cFkH7eYiP469S4jEnYOTv1RlLSfZD5XzVzEaB5RGn+b+qJEiaUNNGwD3bn7Y5j/1aGaIxB5QINB9K+ISOmtNDnb0ayiaHpxrvCDtSoijqWY4vOZtrh+EVmITUR0aU2nukcd8cZrS6I7eL4FowPSgssRId+veSxj1f930sVsAEOdUBx7LI6eTe0L+pC2QWlRLvxJ9LEJcvQ00C2nzQC+fc4JfiVkJGk6xgb/80TWtMSjT1gZxTolMgijZJUzTyFywU91svK3tTOrRBnsjMZFVwV/lb38tWoKHjJCSVeQTAR8mpc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 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: VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(376002)(39860400002)(346002)(396003)(136003)(46966005)(5660300002)(44832011)(2616005)(956004)(70206006)(36756003)(70586007)(36906005)(316002)(86362001)(6916009)(8936002)(8676002)(6486002)(336012)(478600001)(6512007)(47076004)(82740400003)(16526019)(69590400007)(26005)(6506007)(186003)(356005)(82310400002)(81166007)(2906002)(6666004)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 4855a64c-1aac-42bc-f4c9-08d816b47ba6 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i2kUjjmLQ/ChFjehsO186CwsTW8ehFRA7YnwnhJiKPcBT1qy/N9R1HwliMt+wo+nVvfgrqTDvSmDedsgV5trGceUlxi4YQllLl7LJr5LZl4taXVO+P3WotOSCHoE3Svg49gCe5gm28b+v/TDrOHCUTPMRIDumAZ+Z7ZgF1KOE7yqwqKYN/SQAeQchdfZBZfYk8luJpeqCliDSmJIIa40naNieohRu8qty5c64d2Fj4u2rK97+UhWHquU+Ikv/GreY57AGL5yZ5rX79gEF+k059Y28Rxr37FoSHjnSAw4wpLr53LQyOYx9UIFC9oVDDAVlp0mtb4W3K72U8Jhzv3zjWtN8vc4wDA8PVAAQ3eQxh0xqexMDv0gdr/ADA1ucWhcQy8Wom0F2d4W+7caHV7Se1KTbQQEShG0EKXad4Lq1FfdQfcnOz/HYEzc3UbfW8/dts4Do764h5J+V4MVxhiHXQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 13:59:36.7498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a0825b9-206f-4f80-6e21-08d816b47fe6 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3301 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Check BTI support in the compiler and linker. The check also requires READELF that understands the BTI GNU property note. It is expected to succeed with gcc >=gcc-9 configured with --enable-standard-branch-protection and binutils >=binutils-2.33. Note: passing -mbranch-protection=bti in CFLAGS when building glibc may not be enough to get a glibc that supports BTI because crtbegin* and crtend* provided by the compiler needs to be BTI compatible too. --- config.h.in | 3 +++ sysdeps/aarch64/configure | 42 ++++++++++++++++++++++++++++++++++++ sysdeps/aarch64/configure.ac | 19 ++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/config.h.in b/config.h.in index 831eca2fe1..67169e5d01 100644 --- a/config.h.in +++ b/config.h.in @@ -109,6 +109,9 @@ /* AArch64 big endian ABI */ #undef HAVE_AARCH64_BE +/* AArch64 BTI support enabled. */ +#define HAVE_AARCH64_BTI 0 + /* C-SKY ABI version. */ #undef CSKYABI diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure index 5bd355a691..70477a7fa5 100644 --- a/sysdeps/aarch64/configure +++ b/sysdeps/aarch64/configure @@ -172,3 +172,45 @@ else config_vars="$config_vars default-abi = lp64" fi + +# Only consider BTI supported if -mbranch-protection=bti is +# on by default in the compiler and the linker produces +# binaries with GNU property notes in PT_GNU_PROPERTY segment. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BTI support" >&5 +$as_echo_n "checking for BTI support... " >&6; } +if ${libc_cv_aarch64_bti+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } \ + && { ac_try='$READELF -lW conftest.so | grep -q GNU_PROPERTY' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } \ + && { ac_try='$READELF -nW conftest.so | grep -q "NT_GNU_PROPERTY_TYPE_0.*AArch64 feature:.* BTI"' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_aarch64_bti=yes + fi + rm -rf conftest.* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_aarch64_bti" >&5 +$as_echo "$libc_cv_aarch64_bti" >&6; } +if test $libc_cv_aarch64_bti = yes; then + $as_echo "#define HAVE_AARCH64_BTI 1" >>confdefs.h + +fi diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac index 7851dd4dac..798f494740 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -20,3 +20,22 @@ if test $libc_cv_aarch64_be = yes; then else LIBC_CONFIG_VAR([default-abi], [lp64]) fi + +# Only consider BTI supported if -mbranch-protection=bti is +# on by default in the compiler and the linker produces +# binaries with GNU property notes in PT_GNU_PROPERTY segment. +AC_CACHE_CHECK([for BTI support], [libc_cv_aarch64_bti], [dnl + cat > conftest.c < X-Patchwork-Id: 39719 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C600F3887013; Mon, 22 Jun 2020 13:59:51 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60074.outbound.protection.outlook.com [40.107.6.74]) by sourceware.org (Postfix) with ESMTPS id A34B03887002 for ; Mon, 22 Jun 2020 13:59:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A34B03887002 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=DH7R+z2S7C3zS1+fHoOGSPKmEQ+2U8QjLTpUzlfhUik=; b=OKHqJ/yoxgQpQUqnj/rl6PISat/hX4Zhm+Jtada/LQVf4wvXfhgDpkxYEbmEi9IqpNsvhcQgJrWuDdi+zyxgogZj2/XyQKEohvjunsF5NbhuUGcyq3mML8dMzMJ3MM/piMk0//8kaMOwk0VfKfnMVLMirdBqK17ntcsMkxzjhrc= Received: from DB6PR0801CA0061.eurprd08.prod.outlook.com (2603:10a6:4:2b::29) by AM6PR08MB3926.eurprd08.prod.outlook.com (2603:10a6:20b:a7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 13:59:47 +0000 Received: from DB5EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:2b:cafe::d7) by DB6PR0801CA0061.outlook.office365.com (2603:10a6:4:2b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT047.mail.protection.outlook.com (10.152.21.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:47 +0000 Received: ("Tessian outbound 147ff5d152c1:v59"); Mon, 22 Jun 2020 13:59:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ed015d6ca3ad9e53 X-CR-MTA-TID: 64aa7808 Received: from 8ef6534be6ce.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F63AB649-C234-485A-92F0-831FC71411DC.1; Mon, 22 Jun 2020 13:59:41 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8ef6534be6ce.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 13:59:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ds+sUdNaAaLuesPw9fOmSrVLAwV1EyLTiMf8FIBmIwvTpdw03mwphTMMXBcaYjRZlQIDA17hXjjxzEfmiB8FFoD2q/r87g0HtKeeey0iERFGtVNlaNWAaiNHvY2rayS3H3ktv8n5bHUiZe7tNWOh9jbNKM5+mp7V4ibcUzucAdu7M6QC+q5vGJe2oSrdMFjnPgsTB1xPaYmEIcRkYudhyy7zF/zpBCs7bCQ8sOXwekm/pyBgfxoB9Jce7uAwKl+WToSsQfpLtl64sWXeQc0gWzGHOQeF+A/ghuL4X8UMownjJjMxAr/OrIY18HhD14K6REPdprqhJEaOQXI2pp2Fiw== 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=DH7R+z2S7C3zS1+fHoOGSPKmEQ+2U8QjLTpUzlfhUik=; b=lfEULW4rDQB2oNwSAV2+XZ7l1jhCvaPi15bYgoCL1Ogdm8DME0Ceg+VL7rY+jaeNr0vet23RF2W20DZHY46DeaUSe23myioOAgRHywng2wFxHHLPNV5GUmw4FEtZlongKnn8iWHHETkF/s1iWd0wXMweOyZbEEqm17gkXOIMvRLW3K/jjntQYMJU4hwzN7HPnEoN4UP0kmQyuhBG7X6g3Yz6OEdxFX1KB2LdBuozmSop0qOpPYhxyP2dfHLEM4HBydltSaRzWHfWIdNFZN1VkDRrq5fQWU6dCR/M1HhBVE6qSevrlz5pH7oka9Wrp66ujBY16S1YwuAxfV3mzMJcgg== 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=DH7R+z2S7C3zS1+fHoOGSPKmEQ+2U8QjLTpUzlfhUik=; b=OKHqJ/yoxgQpQUqnj/rl6PISat/hX4Zhm+Jtada/LQVf4wvXfhgDpkxYEbmEi9IqpNsvhcQgJrWuDdi+zyxgogZj2/XyQKEohvjunsF5NbhuUGcyq3mML8dMzMJ3MM/piMk0//8kaMOwk0VfKfnMVLMirdBqK17ntcsMkxzjhrc= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 13:59:40 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 13:59:40 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 03/14] aarch64: Add BTI support to assembly files Date: Mon, 22 Jun 2020 14:59:32 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: CWLP265CA0302.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:5d::26) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by CWLP265CA0302.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:5d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:38 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 25072046-53c1-49f5-473c-08d816b485fb X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|AM6PR08MB3926: 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-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 4j4YX/ZN5NakjMRk4+C6Tu55nLLx9etnBmQXcL8vGqd6lPzRJDMdHpdw82WC8LMKNBsOJ/IwSC7Ef+A/VVawGLXw3N1DaK7zBTp2iWWknctu/Xhx26B/HqeuC6l1V3ISB60RbBvlKmMkEAdfqzPkV/Uo++91iQ9vkR562eHbTCVqXg5k4mJjDMuGfu4u3Rq024FVFMncUwQBMnHviHLH+5+aoL7Sd7SSurwi71TEyyZYGPmCYcMB8EDQH8vk1AZPonD5e673DpcVPu+VbAbfG2UC4P+QiXyou1yyzbjJO9fj63iGxjVbzD0fyOKFmPRKE4vTVL6ZMTKb+XWFsMuhF6DedfoQT9iD2GUo8nC3bL+MjN+4kmU720xQPdvEqz7dMESnn0KCNu+AcWMsOxdsKItYkBDS4IUraQZhEify5zM= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(83380400001)(4326008)(86362001)(6916009)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dq9LAVrrvs08B3zWGhGh3AKugVwBoM4LkZlsjELGnSaAtDYIUrRabHHA2HdfQ4ZVsYzAATakyo6vYtRmtwCNjylE+y2CccrX3M3963puMrqLuhgQoj5+DjiHCaoXajFT/LPIpWbRjlcWSVS9d8fz0Ns9aNv064mCVZWdaBhvvJeP9MvKMGNDp4Xtmgo0q7QQtqtu+gFSnNSYc6/UHmUdqvBOYOxaGMzV5CnP04WK96bGFP3rimsu3isJGBW/+p8FPXxzB0EV0Qx8GqV4QplCBreuNovlwKkTK8Mv3yexpY2GlcTRFAtEbC50wdPzQIIAysMjMH3CI6wxXJbVsMV38txNkwrGRTa7MXNpvdPnsvH1Ph7C87QcBAWgLgVWPXm4F9jETkqmeGGyCQjzCGe6YhcU91Ea2n8CUPaiq0Xg8tc8KgtSkQWWU8rbT7fi2BAiFxdXwQ2O1q1KCwExsnP0J8Bg6yAUdMR4TreJN1+zAH9W77UgOtolX7mIaa39hFDN X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 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: DB5EUR03FT047.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(396003)(346002)(376002)(136003)(39860400002)(46966005)(356005)(4326008)(6506007)(8676002)(82310400002)(186003)(336012)(16526019)(2906002)(6512007)(26005)(8936002)(36756003)(6916009)(6486002)(316002)(478600001)(81166007)(83380400001)(70206006)(70586007)(5660300002)(6666004)(956004)(44832011)(86362001)(82740400003)(47076004)(2616005)(69590400007)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 33ac9f7b-6694-48e3-08fe-08d816b48121 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j3Nakn3UxBBTAOgTPLAAgX6Psc8JgXM5kbnR16I8YddH9mgAZKJ94D/GDd/JzHtGfSZsZtwHpLbv32X5mbeBc1kBmATyBSii3miR7nLw2UDD+HJ8sgIZ9M45fcEK6ivwbbRTt/XrcYqe9thBJ4EM0kOt3SOSV071M0CuP2b7QhZNIFhPl2KyXVdrBa9G+wwSvAGO80r+NBd+AXio+dph978BbP562GNxs+K1njjVEOeqLXSN99gcMb7O/gp8CapCy7nk90QouBnCw1Q0HszR9nrqLuqVw+PMd5o7vXIggilTAyeK99AlfUJ0lkNPnH52hnQ2A3WRB590P35N6VtcmU+liZyWTw/XKLvmIeVgP4r7ukwUv6gwUSg2jU02bQEhYqHmouKHF4J+o3zyAuwmS+PF0KmgPLWE1e9E6sDJ3QAJZ9sUzueSobOr9qNrO8UtYhYF+j6Y748MN3yWhUxHbA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 13:59:47.0617 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25072046-53c1-49f5-473c-08d816b485fb 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3926 X-Spam-Status: No, score=-16.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_STOCKGEN, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sudakshina Das Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Sudakshina Das To enable building glibc with branch protection, assembly code needs BTI landing pads and ELF object file markings in the form of a GNU property note. The landing pads are unconditionally added to all functions that may be indirectly called. When the code segment is not mapped with PROT_BTI these instructions are nops. They are kept in the code when BTI is not supported so that the layout of performance critical code is unchanged across configurations. The GNU property notes are only added when there is support for BTI in the toolchain, because old binutils does not handle the notes right. (Does not know how to merge them nor to put them in PT_GNU_PROPERTY segment instead of PT_NOTE, and some versions of binutils emit warnings about the unknown GNU property. In such cases the produced libc binaries would not have valid ELF marking so BTI would not be enabled.) Note: functions using ENTRY or ENTRY_ALIGN now start with an additional BTI c, so alignment of the following code changes, but ENTRY_ALIGN_AND_PAD was fixed so there is no change to the existing code layout. Some string functions may need to be tuned for optimal performance after this commit. Co-authored-by: Szabolcs Nagy Reviewed-by: Adhemerval Zanella --- sysdeps/aarch64/crti.S | 2 ++ sysdeps/aarch64/crtn.S | 2 ++ sysdeps/aarch64/dl-tlsdesc.S | 3 +++ sysdeps/aarch64/dl-trampoline.S | 2 ++ sysdeps/aarch64/start.S | 1 + sysdeps/aarch64/sysdep.h | 34 ++++++++++++++++++++++++++++++++- 6 files changed, 43 insertions(+), 1 deletion(-) diff --git a/sysdeps/aarch64/crti.S b/sysdeps/aarch64/crti.S index 1728eac37a..c346bcad72 100644 --- a/sysdeps/aarch64/crti.S +++ b/sysdeps/aarch64/crti.S @@ -75,6 +75,7 @@ call_weak_fn: .hidden _init .type _init, %function _init: + BTI_C stp x29, x30, [sp, -16]! mov x29, sp #if PREINIT_FUNCTION_WEAK @@ -89,5 +90,6 @@ _init: .hidden _fini .type _fini, %function _fini: + BTI_C stp x29, x30, [sp, -16]! mov x29, sp diff --git a/sysdeps/aarch64/crtn.S b/sysdeps/aarch64/crtn.S index c3e97cc449..0c1ef112c2 100644 --- a/sysdeps/aarch64/crtn.S +++ b/sysdeps/aarch64/crtn.S @@ -37,6 +37,8 @@ /* crtn.S puts function epilogues in the .init and .fini sections corresponding to the prologues in crti.S. */ +#include + .section .init,"ax",%progbits ldp x29, x30, [sp], 16 RET diff --git a/sysdeps/aarch64/dl-tlsdesc.S b/sysdeps/aarch64/dl-tlsdesc.S index 557ad1d505..9d96c8632a 100644 --- a/sysdeps/aarch64/dl-tlsdesc.S +++ b/sysdeps/aarch64/dl-tlsdesc.S @@ -74,6 +74,7 @@ cfi_startproc .align 2 _dl_tlsdesc_return: + BTI_C DELOUSE (0) ldr PTR_REG (0), [x0, #PTR_SIZE] RET @@ -95,6 +96,7 @@ _dl_tlsdesc_return: cfi_startproc .align 2 _dl_tlsdesc_undefweak: + BTI_C str x1, [sp, #-16]! cfi_adjust_cfa_offset (16) DELOUSE (0) @@ -142,6 +144,7 @@ _dl_tlsdesc_undefweak: cfi_startproc .align 2 _dl_tlsdesc_dynamic: + BTI_C DELOUSE (0) /* Save just enough registers to support fast path, if we fall diff --git a/sysdeps/aarch64/dl-trampoline.S b/sysdeps/aarch64/dl-trampoline.S index 94e965c096..2cbfa81434 100644 --- a/sysdeps/aarch64/dl-trampoline.S +++ b/sysdeps/aarch64/dl-trampoline.S @@ -35,6 +35,7 @@ cfi_startproc .align 2 _dl_runtime_resolve: + BTI_C /* AArch64 we get called with: ip0 &PLTGOT[2] ip1 temp(dl resolver entry point) @@ -126,6 +127,7 @@ _dl_runtime_resolve: cfi_startproc .align 2 _dl_runtime_profile: + BTI_C /* AArch64 we get called with: ip0 &PLTGOT[2] ip1 temp(dl resolver entry point) diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S index d96cf57e2d..75393e1c18 100644 --- a/sysdeps/aarch64/start.S +++ b/sysdeps/aarch64/start.S @@ -46,6 +46,7 @@ .globl _start .type _start,#function _start: + BTI_C /* Create an initial frame with 0 LR and FP */ mov x29, #0 mov x30, #0 diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h index 604c489170..4664329d3a 100644 --- a/sysdeps/aarch64/sysdep.h +++ b/sysdeps/aarch64/sysdep.h @@ -41,12 +41,42 @@ #define ASM_SIZE_DIRECTIVE(name) .size name,.-name +/* Branch Target Identitication support. */ +#define BTI_C hint 34 +#define BTI_J hint 36 + +/* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */ +#define FEATURE_1_AND 0xc0000000 +#define FEATURE_1_BTI 1 +#define FEATURE_1_PAC 2 + +/* Add a NT_GNU_PROPERTY_TYPE_0 note. */ +#define GNU_PROPERTY(type, value) \ + .section .note.gnu.property, "a"; \ + .p2align 3; \ + .word 4; \ + .word 16; \ + .word 5; \ + .asciz "GNU"; \ + .word type; \ + .word 4; \ + .word value; \ + .word 0; \ + .text + +/* Add GNU property note with the supported features to all asm code + where sysdep.h is included. */ +#if HAVE_AARCH64_BTI +GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI) +#endif + /* Define an entry point visible from C. */ #define ENTRY(name) \ .globl C_SYMBOL_NAME(name); \ .type C_SYMBOL_NAME(name),%function; \ .align 4; \ C_LABEL(name) \ + BTI_C; \ cfi_startproc; \ CALL_MCOUNT @@ -56,6 +86,7 @@ .type C_SYMBOL_NAME(name),%function; \ .p2align align; \ C_LABEL(name) \ + BTI_C; \ cfi_startproc; \ CALL_MCOUNT @@ -68,10 +99,11 @@ .globl C_SYMBOL_NAME(name); \ .type C_SYMBOL_NAME(name),%function; \ .p2align align; \ - .rep padding; \ + .rep padding - 1; /* -1 for bti c. */ \ nop; \ .endr; \ C_LABEL(name) \ + BTI_C; \ cfi_startproc; \ CALL_MCOUNT From patchwork Mon Jun 22 13:59:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39720 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB960388A819; Mon, 22 Jun 2020 14:00:04 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130081.outbound.protection.outlook.com [40.107.13.81]) by sourceware.org (Postfix) with ESMTPS id A2BC53887002 for ; Mon, 22 Jun 2020 14:00:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A2BC53887002 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=eLWElF3mAZy1E7ngrHBqKVIH9XhWqMLOAuLRud8Zgog=; b=HAp5F2ZS7EqiAtS0uFfyHyQTR0MZw+DBDu8qlbovKLMDKRJb4AAQvWRhHTtQpQnRjtTbQgKBZoshHUdlxWkBSSYsnmo/pymZDm3wcvcYtu1CRZvk6QzQPtfv0L9V+A5+jzrQoBIB6RzmicXzTkjUWg7n6LlMTX9wLmTPHg7UMek= Received: from DB7PR05CA0044.eurprd05.prod.outlook.com (2603:10a6:10:2e::21) by VI1PR08MB4558.eurprd08.prod.outlook.com (2603:10a6:803:ff::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:00:00 +0000 Received: from DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::26) by DB7PR05CA0044.outlook.office365.com (2603:10a6:10:2e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Mon, 22 Jun 2020 14:00:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT038.mail.protection.outlook.com (10.152.21.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:00 +0000 Received: ("Tessian outbound 8fb20e43acb7:v59"); Mon, 22 Jun 2020 14:00:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8045de92ec4f8c27 X-CR-MTA-TID: 64aa7808 Received: from d44863e94dbd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0CDF4BA1-9E05-4DC8-991D-B2A4A3A3C753.1; Mon, 22 Jun 2020 13:59:55 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d44863e94dbd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 13:59:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bsh0PoH8zl9JeKPZuu70CcYO9oE9LxNwyRcTV+RAz+oztj1IqgrTw90He07rDdgaNNWucIXf5lB6XG4+3rfJfdtsicgfgVouSmdmKTM+kqRgveF2Ht+6cg/kG17OCvRsqLFTYC21gB5T6RiLiNRH6KO5yjlIg1lz7tcm25lcIgMAU5NvuHM7MMcnW+TrJE5V9ohMHxpcMX9djyQUBK1Du9HAAZmRuH19lD+CphbKQ/rimpeqGmWcsR4PGuFobMEfaoemFFX2lbVo3LW21+yROOLrrawCxUXc8U5V0xS/qregQwM8d0bhGZ1F4d2V+tt9jsYmp/o/GktrVup2tkm68Q== 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=eLWElF3mAZy1E7ngrHBqKVIH9XhWqMLOAuLRud8Zgog=; b=aZmnPRYrj8SVTVXApkDn7eBubW+Io7rYJuecQTbEvUKijAjxrilr+zfJSIR9phLRVyxq+0IOuLQ6F8ef5wLw7rqXWkxUZfHEyD4B7d8u35+uG7hODbhuTuH6iiG8YtJ1r3UQwTkytUOsOw+fmaftixddtoqjMC2FU4TLDWhIsQVPkFD2qzsMlxp6MlRzFCQ0eQMaEqDbc3dhS2mFV1iidJlHr9PolnJciFWkAHZg8tyNALMNfzyIu++1trK1YSpoesS4UEStQoOvUGZMGloMZIJTf47CUJ8glLbFVuku5dwqujHaA3GHvxPBEuHa+WOtnjoIZnLsylQKVh5n0sDjTw== 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=eLWElF3mAZy1E7ngrHBqKVIH9XhWqMLOAuLRud8Zgog=; b=HAp5F2ZS7EqiAtS0uFfyHyQTR0MZw+DBDu8qlbovKLMDKRJb4AAQvWRhHTtQpQnRjtTbQgKBZoshHUdlxWkBSSYsnmo/pymZDm3wcvcYtu1CRZvk6QzQPtfv0L9V+A5+jzrQoBIB6RzmicXzTkjUWg7n6LlMTX9wLmTPHg7UMek= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 13:59:54 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 13:59:54 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 04/14] aarch64: Rename place holder .S files to .c Date: Mon, 22 Jun 2020 14:59:43 +0100 Message-Id: <26245e2725ad815bbfcd18f58515de4a88cc03e0.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN4PR0601CA0010.namprd06.prod.outlook.com (2603:10b6:803:2f::20) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by SN4PR0601CA0010.namprd06.prod.outlook.com (2603:10b6:803:2f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 13:59:53 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 271a85b4-7214-4589-7d40-08d816b48e34 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|VI1PR08MB4558: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xahNemEplhcv5y98aSFvvnXCkGaS292S43ucJ+JTaC1U/g+TTk7m3gvbrm7Lgq2ZWXk+fNZjUx486ki3TGnBFYLLGLZ7ZqIUDW/M/v/JElvWCI2rHbxBhkVlACZbI0Fhr1xBeP1GVaQ67yuA7RXXUK0wHTpm4+6zlnDyBARcUhG5vOp8cgxCFu3XlArnpd+0nhMlYkIoK1u6wgwqz7lX7tqBZkjW0nrVDQhI9yvV8AiQNrMDoPmDD/ypKn19DVCo5LqTZ70DerxI/0bzF9eNe2TBbKiCjj4gCuBXNSzypdE4ox+U1RbzYy2AXYp0BomJc7HRekgAW7OmUHli/ueOlz06yxB9DPh6dQeMj9j2rK8+swZl7+AZFAk2PhDC3ydL/WP/vwtkUL611lS/s2d3Av5Mt52sqPLKYwX0gDCO3G60x88n/VxScODJGb5ywDMu X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(83380400001)(86362001)(6916009)(142923001)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: QfyFz8ON0X6d+9N2He2O2ZuJe3ixW6nXHPYfgi+jihN91zxoJJYwWnyr2yKOtVKvIKt9jP1yf9sgs4DGAhIpvnMgFW1nDnXDUodo/ozdbnERWzR2f1k8DH6RnRYSVEPvR66DNL0To+AXK6S9EKCdHvHvLpJ23yMYu0/nv73JkEHVEujb6OU3C+Ffu6G1FdrHeFRG2F5EzcIXSjd4Bi5ihK+V/yFQ9YgAcr+wo1uH/WeTgc0R3WVfFXT586UUr5rWLgwAvJhTUfHT0Z1HkyTkiakUIEXJzVR4a4J0aYq+QU6QXO62ElchiVUT+AtuGVOJsA+U6hyoNFbCZZrUtMQJ9L0Htau4mKwkWIB+cyfbIHaUTGOubza/d4JL9LI0+6kL3WUENloIVxrdm02y+B2UPZKqtJD10+NtV0Gt3SkektX+6Ey7eilnl44WwvIcx256s0M88OrrDYkOG97KvPaQ557CBgAK4MH3dkXfL4y3HqS2pKyTYE+ok9WxJWwxX6kg X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 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: DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(136003)(346002)(39860400002)(396003)(376002)(46966005)(5660300002)(336012)(478600001)(8676002)(8936002)(6486002)(81166007)(2906002)(6666004)(16526019)(82310400002)(83380400001)(69590400007)(6506007)(186003)(356005)(82740400003)(6512007)(47076004)(26005)(956004)(2616005)(44832011)(70586007)(36756003)(70206006)(316002)(86362001)(6916009)(142923001)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 834815b6-98c0-47c6-8664-08d816b48a10 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yoVLvI6vv7rjMDBEoNVi4y9HqQx0yDdO9F8nLmrFn2+Tf4fkm3rzQgdAh3CO2oX3RKABc0HDocu5tjS+/HXK8v9pCsA7pLOcw2rkrH0V0t8c6y2mb1NXTHDWDu2leYAoqYldV0NvBYR74+OgOXpVQBosjPG8POBJyGItr5biUDQnB1qGR8YUJ3qQUj463arR15zZWlmYWdqmNCyBE71tfYHYNOwHkrZc5qGIiZiQ1ApxcGBQER4LxV9FuFALV4zY3HSBMZjuFvSm7Cr3DNpsaAxPd9LZK7ReemJcwCUyAJTBokUdQFMdpfpwhhfCOWEkeoFGdN4UfFEwLHospaOVkrOaIteb748pdUU2hvAJoGC/hlSK1uZOix6PS81zh8PySTM/sa/KUC5VfZMLMBMHywBMKHFTHs+gpXCoYW7K6nSBvRHZWFZJP1kj8iaZRiXccmpYk/7TAJGM1yVP9ZIGzcvst3FlyEy7eDhzSUo0Qwlx7oxIoBBiPxvJx+GkcUmd X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:00:00.8574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 271a85b4-7214-4589-7d40-08d816b48e34 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4558 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The compiler can add required elf markings based on CFLAGS but the assembler cannot, so using C code for empty files creates less of a maintenance problem. Reviewed-by: Adhemerval Zanella --- sysdeps/aarch64/{bsd-_setjmp.S => bsd-_setjmp.c} | 0 sysdeps/aarch64/{bsd-setjmp.S => bsd-setjmp.c} | 0 sysdeps/aarch64/{memmove.S => memmove.c} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename sysdeps/aarch64/{bsd-_setjmp.S => bsd-_setjmp.c} (100%) rename sysdeps/aarch64/{bsd-setjmp.S => bsd-setjmp.c} (100%) rename sysdeps/aarch64/{memmove.S => memmove.c} (100%) diff --git a/sysdeps/aarch64/bsd-_setjmp.S b/sysdeps/aarch64/bsd-_setjmp.c similarity index 100% rename from sysdeps/aarch64/bsd-_setjmp.S rename to sysdeps/aarch64/bsd-_setjmp.c diff --git a/sysdeps/aarch64/bsd-setjmp.S b/sysdeps/aarch64/bsd-setjmp.c similarity index 100% rename from sysdeps/aarch64/bsd-setjmp.S rename to sysdeps/aarch64/bsd-setjmp.c diff --git a/sysdeps/aarch64/memmove.S b/sysdeps/aarch64/memmove.c similarity index 100% rename from sysdeps/aarch64/memmove.S rename to sysdeps/aarch64/memmove.c From patchwork Mon Jun 22 13:59:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39721 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1AB5F388A81D; Mon, 22 Jun 2020 14:00:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60077.outbound.protection.outlook.com [40.107.6.77]) by sourceware.org (Postfix) with ESMTPS id 20EAD3840C0E for ; Mon, 22 Jun 2020 14:00:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 20EAD3840C0E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=1B/jWlnGw6SE/g7p1Ew3WX2EXXdb7IFvovtKhBA1zHE=; b=C+NK1G19nY/YOo52NcCJ+4Nsqz2cr67Bwt4lwbA15UGOvLMm6BWf4vMoWeGj9+DdaiyB8hqkBnOBrVNQ3Tt/GlSQbhfYbSTMK8GKygHFdkbAZwIhjBeMLiZJDEfYA63fm6UdX1QMFLa2tdPelHyOfbFUyceH1Rx6TJVDfSq2pJo= Received: from AM6P191CA0052.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::29) by DBBPR08MB4806.eurprd08.prod.outlook.com (2603:10a6:10:db::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Mon, 22 Jun 2020 14:00:10 +0000 Received: from VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:7f:cafe::e9) by AM6P191CA0052.outlook.office365.com (2603:10a6:209:7f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT038.mail.protection.outlook.com (10.152.19.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:10 +0000 Received: ("Tessian outbound 8fb20e43acb7:v59"); Mon, 22 Jun 2020 14:00:10 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bcff2522097c7f06 X-CR-MTA-TID: 64aa7808 Received: from 65e7793ae293.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6BDE2E6E-7411-4AA6-B00B-DD155984CA48.1; Mon, 22 Jun 2020 14:00:04 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 65e7793ae293.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:00:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JbECc5rk9A7uIConvQw+sKLpQr3NqEmToO00J32pFqdfhwMPwmqSEoJJb92b4Bxmvt+i1QHIXU1h7AiTqdJx81mbIRl30IpgJFA2E/G8Sldsmr9ecl5eQ3W5sZyE2XKd+5UbBz7+ZTWKVvIMTTWHZJPW8SiVMcFeLJqkKrpsBlhgZjEAmg+PEIGFaqmeNdvZH63WdtmQ0sfxjRbxQMAnfIeH1/EMd2FHJTZ84nopQaQlbBk8MXYMHAVIoK4NCGuHASOgYPyB/x4+S0PAIpeaESj2Kz58Kh5Xk/TLsFlGlZ/8MRt1kPAs0tsMpt8keEDjy0EqWbYk77tuIFxzsVwtzA== 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=1B/jWlnGw6SE/g7p1Ew3WX2EXXdb7IFvovtKhBA1zHE=; b=Xprn0NBeOEMgIw42vqUNSMU2/RsD4b9fMOZZlx7hv9elK/9sHqhdq+pIkXpQxT8QWeBlgoqaxCFm0N/BZPWEoQCC+HqKoIbK6vyqPJjpngRkEsFi19lj5s538P98bKunDOZInWrkBriqMdXJ2USIwRXMSExF2ZAg5Y9JRZyuuFycpO8M+clWIsFcBgYGD9n4rDRo+ym8M4T812+pyCI00OUTf2UEcoeHvuyJ7yf203NGJIr1BAvkKVjt2Os5XFLAmisquu8rfytmITwOKJeN+YWTorRMyZDLj33x7Of9ab8faH3yx+kIxKd7qpl6TaX9rLXHMM6l2Yms6RJeLVRS7g== 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=1B/jWlnGw6SE/g7p1Ew3WX2EXXdb7IFvovtKhBA1zHE=; b=C+NK1G19nY/YOo52NcCJ+4Nsqz2cr67Bwt4lwbA15UGOvLMm6BWf4vMoWeGj9+DdaiyB8hqkBnOBrVNQ3Tt/GlSQbhfYbSTMK8GKygHFdkbAZwIhjBeMLiZJDEfYA63fm6UdX1QMFLa2tdPelHyOfbFUyceH1Rx6TJVDfSq2pJo= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 14:00:03 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:00:03 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 05/14] aarch64: fix swapcontext for BTI Date: Mon, 22 Jun 2020 14:59:57 +0100 Message-Id: <72d607dcade45c73c3f979d5f8ec1064c15a98b5.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0156.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::24) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LO2P265CA0156.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.24 via Frontend Transport; Mon, 22 Jun 2020 14:00:03 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 63fd3a6f-fa01-41e5-6fed-08d816b493e6 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|DBBPR08MB4806: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: T2Yc4yEf5XyfcLV69EvbAw9hAbKGpRq92xOSXrKjSVBXAl7jB/HR4SQmUrI2fHsxq5ZW3dRB9MpuIneN92JTUuHmFE3+azlW1G/d2NrqjlTVb5nnOgZ2o1G9qmM7I8pZvoNiQf+KvvLGVDl/blfBjOG0MQ/Mzf1aTKvUJ2r9UGHHBHVe7fwX4PFn2IZkNsRqJO5SQ2qlBEeYooO29fMa5FCkV5Hcz9JsEXus6lQAegyLfMrk5mliFal16dHatCuFRV2m6SdXdka04pco7axhHTmq2lI6gYvhKmWOa/HONNaOVzWIU/ivASYSMsl13AgGv0BWeMbc2Vsp2J9vYwom28pirp4yvNLuhc1aKKnoxW/kC1a9gQvKYy4pkUS5QFdDQbvg8spNH7jfsc+3e2hlwqlm/ATn6jxPXhFPWE+M3+g= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(83380400001)(86362001)(6916009)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3dIYAWb/Shmg/kgnMofhcbXic96iYrMgL/tZo/3NFBtu+fLFBFiPBlfIfjTLKQU7qPVpJJB9UxL+Vj4z9kEFyDKaC/YDxPMDFT7A8oHJLd3vKnlQA5whQyufeM+Jweelc/GYg7Q1t1PUM2lu1y5Qeu9w18YxlMhsrijPZcZlp0q3J53ZcOo26hTjM0g+LSlAYSK3lBV4L8afnqpyXOZuiy6bt+SJZiQkIthI0+bpN9UriTca+byfYN9oJZLKvQjLTz0yJm+OaU0Ee3bzN2TpOWSs7HDhw+POk8oZjZawc2PY/FolivkX8Cz7NHxyD+J8tTMB4gGKMXiPIkUC1RivuqbNLSt72Bhrd36iTaaoLlXdUj7mw33rfmiPp59wW2EF6J8CUrxVHGh8uMvMa1tRIFn65rqT8cWccaT997J2Qtwq2Z5O1CNkT2A8omW3Z3aI5vzcbyloZhzZwMLD+4xSkMRD0cNrucfTkZkZ1yUKlUVo8Am4F1asV7hCGS5hcpSs X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 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: VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(136003)(396003)(346002)(39860400002)(376002)(46966005)(5660300002)(356005)(44832011)(81166007)(6666004)(6486002)(82310400002)(2616005)(956004)(8676002)(6916009)(6512007)(336012)(316002)(82740400003)(69590400007)(36906005)(8936002)(47076004)(6506007)(70206006)(70586007)(186003)(26005)(16526019)(2906002)(36756003)(86362001)(478600001)(83380400001)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: e0dc098d-1bbc-4654-e230-08d816b48fa7 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u7K3m2fVuqpX3o33P6Z8LCO8D6OkO7ZwBRPblEuYM+/2iu/IYfyhWHT2f62FiDYslpNHxaPmzgjfimJQ810ML4ZxN6ZQAtP8XwvEDxh33l15q+C1oQlF1sJuti1g8GQX0L6PR2Kejdw7nYiqkMmNssLPglqiWpCuehawjT8hWWZOkYfPYfNdur7QatsibVhEIBhwkhf0Oar1m8S5kHobW6RiDJYWnr1VIu411nsyCG4mQD10MQS6jjcGiAn81LRWppX+4fT4stG6//16fE/+auDtqKuzno+umVZXd2g1RyjaJkP2PmxHKtU+g1kP1/yBGBMJXcqQdshkJ2cFMlx/ZlZwQNm8v1/YWpjq8ljq/2xOA8Aex83iaitWDSGCFhUoeC7iT1wvC/AOqhg4GFd2yGjXlzs8EKWaE5PClqRbW0Z9RJ5pPrO+vkcnDfzjdae6IuP1pQ3Sdbb/rIvReNFyKw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:00:10.3112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63fd3a6f-fa01-41e5-6fed-08d816b493e6 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4806 X-Spam-Status: No, score=-16.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_STOCKGEN, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" setcontext returns to the specified context via an indirect jump, so there should be a BTI j. In case of getcontext (and all other returns_twice functions) the compiler adds BTI j at the call site, but swapcontext is a normal c call that is currently not handled specially by the compiler. So we change swapcontext such that the saved context returns to a local address that has BTI j and then swapcontext returns to the caller via a normal RET. For this we save the original return address in the slot for x1 of the context because x1 need not be preserved by swapcontext but it is restored when the context saved by swapcontext is resumed. The alternative fix (which is done on x86) would make swapcontext special in the compiler so BTI j is emitted at call sites, on x86 there is an indirect_return attribute for this, on AArch64 we would have to use returns_twice. It was decided against because such fix may need user code updates: the attribute has to be added when swapcontext is called via a function pointer and it breaks always_inline functions with swapcontext. Reviewed-by: Adhemerval Zanella --- sysdeps/unix/sysv/linux/aarch64/swapcontext.S | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/aarch64/swapcontext.S b/sysdeps/unix/sysv/linux/aarch64/swapcontext.S index d30c543e6f..f8c66f0ef0 100644 --- a/sysdeps/unix/sysv/linux/aarch64/swapcontext.S +++ b/sysdeps/unix/sysv/linux/aarch64/swapcontext.S @@ -28,8 +28,12 @@ .text ENTRY(__swapcontext) DELOUSE (0) - /* Set the value returned when swapcontext() returns in this context. */ - str xzr, [x0, oX0 + 0 * SZREG] + /* Set the value returned when swapcontext() returns in this context. + And set up x1 to become the return address of the caller, so we + can return there with a normal RET instead of an indirect jump. */ + stp xzr, x30, [x0, oX0 + 0 * SZREG] + /* Arrange the oucp context to return to 2f. */ + adr x30, 2f stp x18, x19, [x0, oX0 + 18 * SZREG] stp x20, x21, [x0, oX0 + 20 * SZREG] @@ -97,5 +101,11 @@ ENTRY(__swapcontext) 1: b C_SYMBOL_NAME(__syscall_error) +2: + /* The oucp context is restored here via an indirect branch, + x1 must be restored too which has the real return address. */ + BTI_J + mov x30, x1 + RET PSEUDO_END (__swapcontext) weak_alias (__swapcontext, swapcontext) From patchwork Mon Jun 22 14:00:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39722 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8157D388A81F; Mon, 22 Jun 2020 14:00:30 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60088.outbound.protection.outlook.com [40.107.6.88]) by sourceware.org (Postfix) with ESMTPS id 17EDB3887002 for ; Mon, 22 Jun 2020 14:00:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 17EDB3887002 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=xO+GjftqZsZae5+TyfKkB+AZBpc/CdAj9KfbqhuP/s8=; b=dYXlLmsaV1K7g41fzyJ8I4kpUurGuGbkHnYTs6x1Uhklu7aF+VvnX1guuRpidtZjXPsKE8NwUqKNpL3sddNZceArG5/uRlBOIGpQwRjoPhC07hol4thaN7S3RQvWsyrDPfHb6Dz8geNOmoz3M/zG0gq1pDQTTw/Te/3P6/L2Jf4= Received: from AM5PR04CA0021.eurprd04.prod.outlook.com (2603:10a6:206:1::34) by VI1PR08MB4480.eurprd08.prod.outlook.com (2603:10a6:803:f6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:00:24 +0000 Received: from AM5EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::dc) by AM5PR04CA0021.outlook.office365.com (2603:10a6:206:1::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT038.mail.protection.outlook.com (10.152.17.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:24 +0000 Received: ("Tessian outbound 022d32fb9a40:v59"); Mon, 22 Jun 2020 14:00:24 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a3f564c2511388ad X-CR-MTA-TID: 64aa7808 Received: from d52b19b3b46f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F6C38426-CB7B-48A8-A751-414C44549B21.1; Mon, 22 Jun 2020 14:00:19 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d52b19b3b46f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:00:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j/aAnapM2x7l+ODJEYUPKK0oQjAhsUdF+CioRaJ31Pk++wG/2Aje7uvgGtI/R7su6Ron8x4TUfE+0POlFyjSj+bunCDbs13GMvGzYwoMnzwZyWS/yQIzqUCzbgJnwRvE2jRkAUErlgYh6VQ8ZY8AooYjQvLF8sUqND9MAIu9ZsvIQCFokkr/+0bsxjpyt5/yQHIOdA4MKxwD820MJNnxRpr3lZS3nS0xjF/Fv7NMfNT9xoufgdav+CXLwgeGNpcRc/+T8tJyLjTEctob3AyN6zAxRHldp2xuCYEOwz1kfSNB28uNC23tSWjLjcZwHKJQIpwINKhkDLv9pJwGJMHdVw== 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=xO+GjftqZsZae5+TyfKkB+AZBpc/CdAj9KfbqhuP/s8=; b=hkTIr7YLd/uugbDrviiaDc8FQqk5lzGvQphtwfEUSfXc5VIetY0Mf1vOB1RXNRikP+PQhObck0q78ugLhy7gzSoFOudyy2sRhpQRPtsoj4iVeUC2eaUi9zY/l/xsV8oUfMQigBAlgdU+jPkLvOxK7caRCo63x70m8QQ7jXcOZ7TugXIXNsuKW7Cr6G16ft0kAzjsIypAktvKEBiZ6QbSfLMChg0eAGNi6soajQ275Y1XYGdGEwSkq9+Vc2oYmPz2BhtZjAHsflJhULqFOWOxhAIncE/w9sulgz1BgcSTY6qUPe+AIHH6Svtrv2wXUa+uMoqpek3qKUVpHW5QQTmDTg== 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=xO+GjftqZsZae5+TyfKkB+AZBpc/CdAj9KfbqhuP/s8=; b=dYXlLmsaV1K7g41fzyJ8I4kpUurGuGbkHnYTs6x1Uhklu7aF+VvnX1guuRpidtZjXPsKE8NwUqKNpL3sddNZceArG5/uRlBOIGpQwRjoPhC07hol4thaN7S3RQvWsyrDPfHb6Dz8geNOmoz3M/zG0gq1pDQTTw/Te/3P6/L2Jf4= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4344.eurprd08.prod.outlook.com (2603:10a6:20b:74::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:00:17 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:00:17 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 06/14] aarch64: fix RTLD_START for BTI Date: Mon, 22 Jun 2020 15:00:06 +0100 Message-Id: <479a62fd3c85faba620481f83e7cf7ae017d8d9d.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN6PR2101CA0020.namprd21.prod.outlook.com (2603:10b6:805:106::30) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by SN6PR2101CA0020.namprd21.prod.outlook.com (2603:10b6:805:106::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.2 via Frontend Transport; Mon, 22 Jun 2020 14:00:16 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b4d86505-d293-46e6-ad15-08d816b49c5d X-MS-TrafficTypeDiagnostic: AM6PR08MB4344:|VI1PR08MB4480: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 7az9TD/MH65bN1kAtkQCTjgp0IwI12UcWdAmnFRyzkMdtMqN02NSSwRljxlT5/C4P45JJVh6vfOlVSSZrppx/J8drJj9cAMaCWeW51Ge8el92Zbji1FcBkqIklghfJyS6r8SsXhAs2z8bNf4dhOVcyf078i1ryeH+ovG+YFeOmxgp3HABNgeJHkhLZ40yNATMAtQwos+YZ2Y8nGnTa7TP6OLXs1t/x+vFmaQQUnOqhVZn5L2+QF56aePf7PWZV3TQVl5A+vvR9ZSBVxxxq/pfCnBAuce0MrqyvcJWxnNK45vpfnLaKGjuEAUzb3q6sNIRHsA7QzMKZnbBGgw1LZ5tPEcnV4Zx8G5EORBbzlro1FiSvt/rmM0fKMCNohdNO5mQ6L/kf/0gp51CIs52N06dydBNc17kGGIx+LV93u2OPg= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(396003)(346002)(366004)(376002)(52116002)(2616005)(69590400007)(66946007)(66556008)(26005)(66476007)(6916009)(956004)(6666004)(6506007)(2906002)(186003)(16526019)(86362001)(6486002)(44832011)(478600001)(8936002)(36756003)(316002)(5660300002)(83380400001)(6512007)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MeyvHB+pd5EdsmGb1RBkwfjMqYMXZ7jAUrVJQ2/TY5+WhzEHhHhpfdq6kQkahu6DUnu1yTDLD+wn6TRlI/ZrIOtPSRxhkXVk+HCoEJH6psDdRnNzJ1Us9DEFb9ytiXQsJPqVBHLfBC/Hcs7cHWa3T6E6mrMGMOKXjjSsyFwED0CK8yLUOYEHyEBbq+iG+nG25VwZ1pGAq7Hwdm66Jjh0k7Eea0sTqv0xhuwaqsBi8nEN9tRx6ZrNJteve60LeKK79i7QPySD6aHSRqEfBpgi0EzhopMutIrKIKESVfsCqS4aCaflsvHPkjwYOxeGUbfsuFx/ljxjBTGQCYuQixyOpcjYBRbEt9dS3EpZ8gi8JGkbkgAgUmdr48SmUzxvSenFHXD/yRfpMYN04EIozshikhrPde2mnXWL40gupu6oGKzfXIREu/IJESKCSwM9GyGBCGXSLoBR5cbLevKSIv6xxemCFupZnHM1fSzKtkokUZo+rzn6A6xLjPCbzHcSUPiV X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4344 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: AM5EUR03FT038.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(396003)(346002)(376002)(39860400002)(136003)(46966005)(316002)(44832011)(47076004)(186003)(356005)(82740400003)(6512007)(36756003)(956004)(6916009)(2616005)(8936002)(478600001)(83380400001)(336012)(6506007)(8676002)(36906005)(5660300002)(70206006)(70586007)(26005)(81166007)(16526019)(69590400007)(86362001)(6486002)(2906002)(82310400002)(6666004)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 7606c461-dc0c-4d10-4c8d-08d816b497fa X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OIi43H9S+uym256RyAMSSpKiLS5mbLZja0klhBv9dxieQOQznZbpesgIQ8M+d7tcTHZ6dBFynG5LYgw0051oa1g1gCWOUaCOCSkTr1FCMcI0uFJPvqGXQNqYXJsK+f0Di51rISTvYexNQtdJOgLLiBXQWheJeCt0SToOkCMhTCakinFcFcrvz7VYt0MkaADMBnR94TSg0R2vCosrPf8uO/B14TwgT1HKSYbGMrLT1pzWneVLODJmNgDse4po6u3Tb4CT2zn92mDNxvcI9XTPWr3OOvx+WysLYH8yAX+xJYRqKzuMDGTOcRvTefOMVXXtprt/r2O7ODlu68tLy5QhFB6M4rEiaFblq7UubJXEPtD3yP3sPh+RfxGHjyntlMpl2rc/oL9/J+bCRelpzsDsnRhKgJn6VkuqZVd9gJNZh+7GfUmWF3Kdrv1ycbmN606RFYj0GHRuZQ4VNDF0bDaTIg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:00:24.5614 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4d86505-d293-46e6-ad15-08d816b49c5d 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4480 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Tailcalls must use x16 or x17 for the indirect branch instruction to be compatible with code that uses BTI c at function entries. (Other forms of indirect branches can only land on BTI j.) Also added a BTI c at the ELF entry point of rtld, this is not strictly necessary since the kernel does not use indirect branch to get there, but it seems safest once building glibc itself with BTI is supported. Reviewed-by: Adhemerval Zanella --- sysdeps/aarch64/dl-machine.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h index db3335e5ad..70b9ed3925 100644 --- a/sysdeps/aarch64/dl-machine.h +++ b/sysdeps/aarch64/dl-machine.h @@ -125,6 +125,8 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) .globl _dl_start_user \n\ .type _dl_start_user, %function \n\ _start: \n\ + // bti c \n\ + hint 34 \n\ mov " PTR "0, " PTR_SP " \n\ bl _dl_start \n\ // returns user entry point in x0 \n\ @@ -178,7 +180,8 @@ _dl_start_user: \n\ adrp x0, _dl_fini \n\ add " PTR "0, " PTR "0, #:lo12:_dl_fini \n\ // jump to the user_s entry point \n\ - br x21 \n\ + mov x16, x21 \n\ + br x16 \n\ "); #define elf_machine_type_class(type) \ From patchwork Mon Jun 22 14:00:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39723 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5A4AE388A823; Mon, 22 Jun 2020 14:00:44 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2061.outbound.protection.outlook.com [40.107.21.61]) by sourceware.org (Postfix) with ESMTPS id 39C1A388A81C for ; Mon, 22 Jun 2020 14:00:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 39C1A388A81C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=r/I6C49AfETRRf+5JGl46eKQFLFBRSDXGmXOjjTmzyU=; b=lpXOB4GofNQC7+V0/8dfjzZ7f3FFPi5rMb0e3PB3Dccz65VSZbKqOYE6W0k/CKF5i4/nBSuh77bDdRuJCQMpkxMWlP2EgbTk3SrddIZ8igKaS6QK6UdEzN+gfFKivBJkibjjmFjXVR6QxvtXXoawWAH1vxk3Sur1iEbMsFdjEAg= Received: from DB6PR0501CA0043.eurprd05.prod.outlook.com (2603:10a6:4:67::29) by DB8PR08MB5098.eurprd08.prod.outlook.com (2603:10a6:10:ec::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 14:00:39 +0000 Received: from DB5EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:67:cafe::6d) by DB6PR0501CA0043.outlook.office365.com (2603:10a6:4:67::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT056.mail.protection.outlook.com (10.152.21.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:39 +0000 Received: ("Tessian outbound da41658aa5d4:v59"); Mon, 22 Jun 2020 14:00:38 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 707b5b0829d97c05 X-CR-MTA-TID: 64aa7808 Received: from a6db87968be2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id ED836238-1B68-42F2-9225-95357352F969.1; Mon, 22 Jun 2020 14:00:32 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a6db87968be2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:00:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KgeySxEKZw2/WZpgItDcXivRztD/G2AUO4wYwtPO3VqjGSLkDRaTUq8QHWkoZIuuAGOmHAfxLt8UOO5rHJOMfa+nr4lzQntWLX4zmkAIo6Qj3D8uqPRRCvodoZ9wngiqKkZs5bU43qaCMlbal2H2uQDo/HhtpSRvzNnPn36E25t30G/iwsFQEoH/WO60Z8yjYs+HLNe/1C2X4mf7C1PdtHKbQLRaALsgtyc0pisMaDj2yUu4B71TkIjkJSpGXhxTTmfZ9PylvYC7KCUDgwLuiNvqinDCEBI3rvwsYtN1j8vP6F8imlY/ejtKt7CP9iDsPSWU5tt5PzaLVTWuA3Jexg== 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=r/I6C49AfETRRf+5JGl46eKQFLFBRSDXGmXOjjTmzyU=; b=S1L8g72LCIgPziC6eSPq8NZ1aG0Wz2QnxJEWPG5u+dKgdFduuRQQqwYdbaP5Oh53mKon0BxO/25eMqcz+Wv0GyvUr5otEBfFKaAVdhCz5iTC4SrUv+IXvA66ionXWStf31EosEWFjqS3i391X43QOd4EDq+iuJCIVgqj1ORH3XQSsIoLta3B+0NekUk3FXhvKSFzl1IKs1FzsVSqgIGWo0X6mmcVHf/BjSH8he8eya3w57cqo8jdGYYJQ94KTtsA2dJ3fYOLa4r4CKaMAY6ObQBYvv1xXXPOPJhyPyomFdKwziDDobvn+2f0BN6UPkqTAz/IndGRzCiekgjRjWXQvw== 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=r/I6C49AfETRRf+5JGl46eKQFLFBRSDXGmXOjjTmzyU=; b=lpXOB4GofNQC7+V0/8dfjzZ7f3FFPi5rMb0e3PB3Dccz65VSZbKqOYE6W0k/CKF5i4/nBSuh77bDdRuJCQMpkxMWlP2EgbTk3SrddIZ8igKaS6QK6UdEzN+gfFKivBJkibjjmFjXVR6QxvtXXoawWAH1vxk3Sur1iEbMsFdjEAg= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4344.eurprd08.prod.outlook.com (2603:10a6:20b:74::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:00:31 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:00:31 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 07/14] rtld: Handle PT_GNU_PROPERTY Date: Mon, 22 Jun 2020 15:00:20 +0100 Message-Id: <2fd3fdf54dcc9cf2c40808bf6b9b95a69038f929.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN4PR0501CA0086.namprd05.prod.outlook.com (2603:10b6:803:22::24) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by SN4PR0501CA0086.namprd05.prod.outlook.com (2603:10b6:803:22::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.12 via Frontend Transport; Mon, 22 Jun 2020 14:00:30 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 866c1f7b-dcb8-4549-104d-08d816b4a4fe X-MS-TrafficTypeDiagnostic: AM6PR08MB4344:|DB8PR08MB5098: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 5+q79baFlI0vFq1YQR+p8/30P2p4p9g/+gpD1x1s/bcm9P/0ULk391OPD629vikQ/Rovtxs8EP0zn+ypMYC7cYatWiJlKyCxdjaO5vdLDI+Uj1hgoPF0Yc8M9ETXvPtbdfMLgrunfM1gFvojwAK8K+VKzIxMwjs095rGxkODjys50kL7wAiFcd+JqC5Zr9N3SDA3laESRhrIB4FlKISJcCptBZLSTYkQt437HTuxShtGAOo44ZiurwqRyDXwE2DTDq85DgE1vaNDyS5AlQ5KFiKwkEQECez1seXS/s/Ms56NmYqb2FLPnJ0s9PNIYgRm+7Ib5bIc8JnWYQrx5EDWghDJciwjh707HHHKKzYq5T0Rr3DHOzolw07Lqx6hZ+9xlgbqHUohmL0b/2o4cqiCLqvqArJ9l7X0BhWY+bl60AY= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(396003)(346002)(366004)(376002)(52116002)(2616005)(69590400007)(66946007)(66556008)(26005)(66476007)(6916009)(956004)(6666004)(6506007)(2906002)(186003)(16526019)(86362001)(6486002)(44832011)(478600001)(8936002)(36756003)(316002)(5660300002)(83380400001)(6512007)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: RJkDWBbaXd64bLoI+647OYl3SDyheV9aqQp01GxQH1g38Y47UArReqONrplQIhLBl3949DLUeq9qR/RCvVbMcb99odaj8EreYiRaa0cQYi5HTOSXOqaS1lhvfbZYBaa7lWiO6sxw8XhV9cAWoSJyfvRZ3C+uGybxmvUaZRDxqCDYIhKidpmrkdskjfLvrHrP4txSoOLPU0GaoDkkZtBzt/OaT/pEL5HzbS9NEYofP31pNP5wkRdC7XNHs7z2KfWbqp1McRM7pCKcNGZ2LfMPdicZcQ9AVW+aYLqSwRYQvwm3PEF+23mUM18rR0N818f+/u9LnQwaftVxcgZ2o83FoMREXnzw1FvAw82WKvdxdLV7utftz/6pX5/OpQqQDTNP54PayTDRoHo8SXNmeeC2KxKPSAsify3q+E0MbVj3Xh6w9XXQu6foIh4f5Bn0ZS8GWZFT4KtrW9OOaJakRaHk1WhTwJAzC6CPfIcv45wXM5/5Y75D31nBg5FXlBwGWwrz X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4344 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: DB5EUR03FT056.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(39860400002)(346002)(136003)(376002)(396003)(46966005)(186003)(69590400007)(6506007)(26005)(6666004)(16526019)(47076004)(81166007)(8936002)(6916009)(36756003)(356005)(8676002)(82740400003)(83380400001)(316002)(2906002)(336012)(86362001)(6512007)(82310400002)(44832011)(70206006)(70586007)(6486002)(2616005)(5660300002)(956004)(478600001)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 1ce17fe1-7eb0-4e26-7b5e-08d816b4a03b X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uXICW8TDED48jpK51O/i0jmKbmLwxNudlMM8MFB+Pq3/rFJPWKgX7CjA7+/PTPuK/m+jL0PKOKg6dJeSKCxpIEcrUIIiwSm5eLeM8+rBgkmTmaXU4xwNsEtN+59Ne27ecORevT0H55ju2BKYjAqBAyRb0YuM328OfEHSQinVpAqVj7XwVW4itS26W0X0HVd74BTL+ukNO1Ywlw1zIsSQsD28Q0AKfWFhiDA4iD1AJ63UHIIoMNNhA6IHol9NwFIIfFhCXMp16wzekw0T6ThYIAIAyGTk6KX8rTHFRwV4u5+QV4mORyomMu7Fhp16CZi8Qzml45CqVV7j9gLgRD9NF+HY9bFnTrCA36xTQhUKYFnDy1s92CS1tNEQ124GzL53rIU+d5OnONPJTkOT9rDGSPUgTau3zVY4lSoA3/lHwYlFkdzkNJd2e/W403IkR47tsizgLTN4C1GW7biGrTpdRQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:00:39.0733 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 866c1f7b-dcb8-4549-104d-08d816b4a4fe 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5098 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Add generic code to handle PT_GNU_PROPERTY notes. Unlike _dl_process_pt_note, _dl_process_pt_gnu_property is generic, has no failure mode (invalid content is ignored) and always called after PT_LOAD segments are mapped. Currently only one NT_GNU_PROPERTY_TYPE_0 note is handled, which contains target specific properties: the _dl_process_gnu_property target hook is called for each property. Otherwise it follows the existing x86 note processing logic. --- elf/dl-load.c | 81 ++++++++++++++++++++++++++++++++++++++ elf/rtld.c | 4 ++ sysdeps/generic/dl-prop.h | 19 ++++++--- sysdeps/generic/ldsodefs.h | 4 ++ sysdeps/x86/dl-prop.h | 7 ++++ 5 files changed, 110 insertions(+), 5 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 06f2ba7264..66bd0ca0a3 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -853,6 +853,77 @@ 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. */ + +void +_dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph) +{ + const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr); + const ElfW(Addr) size = ph->p_memsz; + const ElfW(Addr) align = ph->p_align; + + /* The NT_GNU_PROPERTY_TYPE_0 note must be aligned to 4 bytes in + 32-bit objects and to 8 bytes in 64-bit objects. Skip notes + with incorrect alignment. */ + if (align != (__ELF_NATIVE_CLASS / 8)) + return; + + const ElfW(Addr) start = (ElfW(Addr)) note; + unsigned int last_type = 0; + + while ((ElfW(Addr)) (note + 1) - start < size) + { + /* Find the NT_GNU_PROPERTY_TYPE_0 note. */ + if (note->n_namesz == 4 + && note->n_type == NT_GNU_PROPERTY_TYPE_0 + && memcmp (note + 1, "GNU", 4) == 0) + { + /* Check for invalid property. */ + if (note->n_descsz < 8 + || (note->n_descsz % sizeof (ElfW(Addr))) != 0) + return; + + /* Start and end of property array. */ + unsigned char *ptr = (unsigned char *) (note + 1) + 4; + unsigned char *ptr_end = ptr + note->n_descsz; + + do + { + unsigned int type = *(unsigned int *) ptr; + unsigned int datasz = *(unsigned int *) (ptr + 4); + + /* Property type must be in ascending order. */ + if (type < last_type) + return; + + ptr += 8; + if ((ptr + datasz) > ptr_end) + return; + + last_type = type; + + /* Target specific property processing. */ + if (_dl_process_gnu_property(l, type, datasz, ptr) == 0) + return; + + /* Check the next property item. */ + ptr += ALIGN_UP (datasz, sizeof (ElfW(Addr))); + } + while ((ptr_end - ptr) >= 8); + + /* Only handle one NT_GNU_PROPERTY_TYPE_0. */ + return; + } + + note = ((const void *) note + + ELF_NOTE_NEXT_OFFSET (note->n_namesz, note->n_descsz, + align)); + } +} + + /* Map in the shared object NAME, actually located in REALNAME, and already opened on FD. */ @@ -1188,6 +1259,16 @@ _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. */ + for (ph = phdr; ph < &phdr[l->l_phnum]; ++ph) + switch (ph->p_type) + { + case PT_GNU_PROPERTY: + _dl_process_pt_gnu_property (l, ph); + break; + } } if (l->l_ld == 0) diff --git a/elf/rtld.c b/elf/rtld.c index 882b070cc0..3ad2bf5079 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -1508,6 +1508,10 @@ of this helper program; chances are you did not intend to run this program.\n\ main_map->l_relro_size = ph->p_memsz; break; + case PT_GNU_PROPERTY: + _dl_process_pt_gnu_property (main_map, ph); + break; + case PT_NOTE: if (_rtld_process_pt_note (main_map, ph)) _dl_error_printf ("\ diff --git a/sysdeps/generic/dl-prop.h b/sysdeps/generic/dl-prop.h index 6b0f2aa95a..ceb6f623ee 100644 --- a/sysdeps/generic/dl-prop.h +++ b/sysdeps/generic/dl-prop.h @@ -20,11 +20,11 @@ #define _DL_PROP_H /* The following functions are used by the dynamic loader and the - dlopen machinery to process PT_NOTE entries in the binary or - shared object. The notes can be used to change the behaviour of - the loader, and as such offer a flexible mechanism for hooking in - various checks related to ABI tags or implementing "flag day" ABI - transitions. */ + dlopen machinery to process PT_NOTE and PT_GNU_PROPERTY entries in + the binary or shared object. The notes can be used to change the + behaviour of the loader, and as such offer a flexible mechanism + for hooking in various checks related to ABI tags or implementing + "flag day" ABI transitions. */ static inline void __attribute__ ((always_inline)) _rtld_main_check (struct link_map *m, const char *program) @@ -51,4 +51,13 @@ _rtld_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) return 0; } +/* 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) +{ + return 0; +} + #endif /* _DL_PROP_H */ diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index d08b97a5ef..c525ffa12c 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -910,6 +910,10 @@ extern void _dl_setup_hash (struct link_map *map) attribute_hidden; 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); + /* Search loaded objects' symbol tables for a definition of the symbol referred to by UNDEF. *SYM is the symbol table entry containing the diff --git a/sysdeps/x86/dl-prop.h b/sysdeps/x86/dl-prop.h index 516f88ea80..4a8ebc573e 100644 --- a/sysdeps/x86/dl-prop.h +++ b/sysdeps/x86/dl-prop.h @@ -191,4 +191,11 @@ _rtld_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) return 0; } +static inline int __attribute__ ((always_inline)) +_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz, + void *data) +{ + return 0; +} + #endif /* _DL_PROP_H */ From patchwork Mon Jun 22 14:00:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39724 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B8BDA388A828; Mon, 22 Jun 2020 14:00:56 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60056.outbound.protection.outlook.com [40.107.6.56]) by sourceware.org (Postfix) with ESMTPS id 5C968388A81C for ; Mon, 22 Jun 2020 14:00:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5C968388A81C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=vwk5exaxCsSSvGEQK8zlzQ0wuF05Wn4pKIztSjDQJyQ=; b=agn5cnhAZnHRwGXjm4YNPCVx/kXsHgDfkej+WaVy13ucrvhSY1iI5bK1uORjPV5q9Qub9OwDC8ECIIy5VGtA+sR7c3MDgTT7bCeW2zXIvdk90CpM49oKP+THMmJnw6R1xp0VogNxrz8ZHjT791WFOehL36C8SpQbgkn+aSdWwKc= Received: from AM5PR0502CA0021.eurprd05.prod.outlook.com (2603:10a6:203:91::31) by VE1PR08MB4752.eurprd08.prod.outlook.com (2603:10a6:802:a4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Mon, 22 Jun 2020 14:00:48 +0000 Received: from AM5EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:91:cafe::3) by AM5PR0502CA0021.outlook.office365.com (2603:10a6:203:91::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Mon, 22 Jun 2020 14:00:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT031.mail.protection.outlook.com (10.152.16.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:47 +0000 Received: ("Tessian outbound 8fb20e43acb7:v59"); Mon, 22 Jun 2020 14:00:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 87ced9c2c338f8a0 X-CR-MTA-TID: 64aa7808 Received: from df0e8ed4f6a4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C5E8AC38-CD6E-47D2-93F6-60914F46D628.1; Mon, 22 Jun 2020 14:00:42 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id df0e8ed4f6a4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:00:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TnAqo4GTWskqygj3ItY7tYWAKzMQoQeJrfypdap1iVe8RIJu5sNzD65Acru74Dvh+4PVEgFuf4OcRRxVx17+t7YHULbMdUQMVfx3P4ilmPGXeT1SinxdwB0RbLh3DU8gR6iBwiIy5WKAC5VvssTxNiW6YaYMhru9MttQle+kaS7Cn36Fknuwd4LpT4MkiBtPVmHeh4SJYoCWTx5rc63rmHTJlP+b/+JwdiDk3hSV2uUbG8exr/uZ8z+MeUEXJc/BWwrkbRqW3rEqPLd9pjVzGpdVn6dtTAcvHwrdmVVpVwN6YPoFepDTkUtVg1HCq2nSg/0YOVnqjbIBiL7Eh8hXDw== 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=vwk5exaxCsSSvGEQK8zlzQ0wuF05Wn4pKIztSjDQJyQ=; b=cP9+QqPxlPnUrZ4+PqEhGc01BcZbbQT22cahQfLNiC2EM3my7gMWbL93iGobEjgku61ebjDVI0/c1wxf+orHABXR61Lx7hUbLj72sZPEUhnGRvkgLyoOps51jN6kxdQy2sTXLWkndfkA207ZnbMhd6McQ18lsJNfYhj1wD7ezojdUT4rHg/OW5PqMYOjcz8Y7iBtKdw2T8EOvuCsC32rdHrj4GuDmib8z41iKbtOxawaPJHyn7gk55g+ng602XAz43X5BRrLfuNFFuscTQbO7Pxo66sgr5aiZGNakQpCvhnBYK5lWFZNiI5z9qMU2ZVwFWMdSk3ZxKhS0wPIUq9VFg== 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=vwk5exaxCsSSvGEQK8zlzQ0wuF05Wn4pKIztSjDQJyQ=; b=agn5cnhAZnHRwGXjm4YNPCVx/kXsHgDfkej+WaVy13ucrvhSY1iI5bK1uORjPV5q9Qub9OwDC8ECIIy5VGtA+sR7c3MDgTT7bCeW2zXIvdk90CpM49oKP+THMmJnw6R1xp0VogNxrz8ZHjT791WFOehL36C8SpQbgkn+aSdWwKc= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 14:00:40 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:00:40 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 08/14] rtld: Rename _rtld_process_pt_note to _dl_process_pt_note Date: Mon, 22 Jun 2020 15:00:34 +0100 Message-Id: <3be82491fa7d4ee9efd9118c5021e866c7ef3820.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0107.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::23) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LO2P265CA0107.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.25 via Frontend Transport; Mon, 22 Jun 2020 14:00:40 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3ca52194-da9e-4b37-0c4d-08d816b4aa2a X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|VE1PR08MB4752: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: f/ZZjrOmMQi5x2u60PyoKqB1Q9oF/53uQqSOBNsaoJk2/t+65N5kNqhWHU+TrUWWrZtxO+R/Cjw5IZzt5FojoLFB4lD215bG6XZuftKuOMZ8yrET158a3Qwiq0dTNCJyyHjrSVLzVNni73voFLb9Hr+1cAfvv9dh+5JXT7iL/eZI3zbubSfgZFY9l1Pfa4IOaRgax+tyYA93uwX20ik1OyZyUE03kWmCBcYIDJeyeCZNIPLHLQPSjrvvYQWjZRtiF9e33RLS/ZcHZo5KEerhI+VlwkCwi2FjGiIDeMvxLytJr/5lZttxVg9vhvHXG9d2MeQCtAFZ0E4yEnZMmLf9vBEPoKLoJ4r1JQ0cEJ3Srar34Jsc3PSu+0YXz8xyMq8M/mwZIXiQmQQt7wC/QarXLbbClQEj60u0wupYJGd2t/Q= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(83380400001)(4326008)(86362001)(6916009)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YtzuY8UF5isbLqh8mbgmTBewy09xIOOEMY6i5rpdGCOTqZ51wXVKUhapsQ8J5g2Iyvfzbeziu7CJ6GA2Ej7qK2E79lZxN+mwAy40WJHekAzvI1B0h2ZAFSVyhnosYvYPvfadOPNVGABzu0og4Aecg6NpT2OKbL3/XarH6LnqOyO9fbmhWsshbNzCVIBe1sdHIeS1hZMFJaU8msiRltCDoLj1qjv9oVv/nnXMhHZre9zg8MEs3NDhOxrvKE3WhJw/ol0VJ9I3IQP6QMh1955jlnRy8IAQ89gZH2t5C/E3yIhDmNTzhe+FV9947PR5tBkGhCbBZ6ozojCqZ2R63Q6GJRb7YC0YLgXZqy1q02hCvsoKxmPrJERt0jJ3CVXDbeuxviJQ7kyvjaBubBR61r9sjtEvcW4oTw50wfEZ88RMZRDpWwJe3DuYQVVzj7h8EptyQz9tsywyZslzvVbGEVZuNYOtj6MWpEN/VxVyLF2LU0Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 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: AM5EUR03FT031.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(376002)(396003)(136003)(346002)(39860400002)(46966005)(8936002)(5660300002)(81166007)(478600001)(82310400002)(82740400003)(6666004)(70586007)(70206006)(6916009)(2906002)(83380400001)(8676002)(47076004)(2616005)(6512007)(44832011)(6486002)(36756003)(336012)(69590400007)(956004)(4326008)(356005)(316002)(16526019)(186003)(36906005)(86362001)(107886003)(26005)(6506007)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 54fce58b-6569-4979-3f7d-08d816b4a5d0 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mmIUoulY3/QrGBa64avvrRfjpZcERQ19i6oyoA/kBXd1ScONp8PXRJXBsUMIBbbRgiaQLFEsae/ORPbkIJZ5IL0x5Ra5fvJkGmL4fgfwD3HfucmVt1jj96S6oU3bw6Yw5f28l9W4KaHvRglP5BOqeYGVxsMie/fLhBCRvrh3y1CVL7Qgv/0pzgrosh5PY+OpO2HGuGFk8xT5sXJgUc/AdWHyXL8POsWLdvsCWsOf14pzOmes9nRjPZrwibF2cL/S5dN0h/0aQNNNm8uLWUrYf0Vcewfrp6VuSfDntjubQPbkoyjlj4aCGLxTQRGupou+yC+OVE4BWnREejYTkJ9NifW4II2vBUA7/598sHReUahsBofCVDQn/2hTzKixK8hGIXLs9HShP2oBr6Rs8Yc1rsJFwfFmQvuRk8cpine14BbzNRQ25mW6y46ZRyP1IA64/lhBpO47ap1yxva+FzhTTw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:00:47.7172 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ca52194-da9e-4b37-0c4d-08d816b4aa2a 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4752 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: "H.J. Lu" The old _dl_process_pt_note and _rtld_process_pt_note differ in how the program header is read. The old _dl_process_pt_note is called before PT_LOAD segments are mapped and _rtld_process_pt_note is called after PT_LOAD segments are mapped. Since PT_GNU_PROPERTY is processed after PT_LOAD segments are mapped, we can process PT_NOTE together with PT_GNU_PROPERTY. We can remove the old _dl_process_pt_note and rename _rtld_process_pt_note to _dl_process_pt_note. NOTE: We scan program headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY exits. --- elf/dl-load.c | 21 ++++++++----------- elf/rtld.c | 18 +++++++++------- sysdeps/generic/dl-prop.h | 14 ++----------- sysdeps/x86/dl-prop.h | 44 ++------------------------------------- 4 files changed, 23 insertions(+), 74 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 66bd0ca0a3..32c74f79ef 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1216,14 +1216,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, l->l_relro_addr = ph->p_vaddr; l->l_relro_size = ph->p_memsz; break; - - case PT_NOTE: - if (_dl_process_pt_note (l, ph, fd, fbp)) - { - errstring = N_("cannot process note segment"); - goto call_lose; - } - break; } if (__glibc_unlikely (nloadcmds == 0)) @@ -1261,12 +1253,17 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, goto call_lose; /* Process program headers again after load segments are mapped in - case processing requires accessing those segments. */ - for (ph = phdr; ph < &phdr[l->l_phnum]; ++ph) - switch (ph->p_type) + 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, &ph[-1]); + break; case PT_GNU_PROPERTY: - _dl_process_pt_gnu_property (l, ph); + _dl_process_pt_gnu_property (l, &ph[-1]); break; } } diff --git a/elf/rtld.c b/elf/rtld.c index 3ad2bf5079..f4c2602d65 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -1507,15 +1507,17 @@ of this helper program; chances are you did not intend to run this program.\n\ main_map->l_relro_addr = ph->p_vaddr; main_map->l_relro_size = ph->p_memsz; break; - - case PT_GNU_PROPERTY: - _dl_process_pt_gnu_property (main_map, ph); - break; - + } + /* Process program headers again, but scan them backwards so + that PT_NOTE can be skipped if PT_GNU_PROPERTY exits. */ + for (ph = &phdr[phnum]; ph != phdr; --ph) + switch (ph[-1].p_type) + { case PT_NOTE: - if (_rtld_process_pt_note (main_map, ph)) - _dl_error_printf ("\ -ERROR: '%s': cannot process note segment.\n", _dl_argv[0]); + _dl_process_pt_note (main_map, &ph[-1]); + break; + case PT_GNU_PROPERTY: + _dl_process_pt_gnu_property (main_map, &ph[-1]); break; } diff --git a/sysdeps/generic/dl-prop.h b/sysdeps/generic/dl-prop.h index ceb6f623ee..f1cf576fe3 100644 --- a/sysdeps/generic/dl-prop.h +++ b/sysdeps/generic/dl-prop.h @@ -36,19 +36,9 @@ _dl_open_check (struct link_map *m) { } -#ifdef FILEBUF_SIZE -static inline int __attribute__ ((always_inline)) -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph, - int fd, struct filebuf *fbp) -{ - return 0; -} -#endif - -static inline int __attribute__ ((always_inline)) -_rtld_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) +static inline void __attribute__ ((always_inline)) +_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) { - return 0; } /* Called for each property in the NT_GNU_PROPERTY_TYPE_0 note of L, diff --git a/sysdeps/x86/dl-prop.h b/sysdeps/x86/dl-prop.h index 4a8ebc573e..89911e19e2 100644 --- a/sysdeps/x86/dl-prop.h +++ b/sysdeps/x86/dl-prop.h @@ -19,8 +19,6 @@ #ifndef _DL_PROP_H #define _DL_PROP_H -#include - extern void _dl_cet_check (struct link_map *, const char *) attribute_hidden; extern void _dl_cet_open_check (struct link_map *) @@ -146,49 +144,11 @@ _dl_process_cet_property_note (struct link_map *l, #endif } -#ifdef FILEBUF_SIZE -static inline int __attribute__ ((unused)) -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph, - int fd, struct filebuf *fbp) -{ -# if CET_ENABLED - const ElfW(Nhdr) *note; - ElfW(Nhdr) *note_malloced = NULL; - ElfW(Addr) size = ph->p_filesz; - - if (ph->p_offset + size <= (size_t) fbp->len) - note = (const void *) (fbp->buf + ph->p_offset); - else - { - if (size < __MAX_ALLOCA_CUTOFF) - note = alloca (size); - else - { - note_malloced = malloc (size); - note = note_malloced; - } - if (__pread64_nocancel (fd, (void *) note, size, ph->p_offset) != size) - { - if (note_malloced) - free (note_malloced); - return -1; - } - } - - _dl_process_cet_property_note (l, note, size, ph->p_align); - if (note_malloced) - free (note_malloced); -# endif - return 0; -} -#endif - -static inline int __attribute__ ((unused)) -_rtld_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) +static inline void __attribute__ ((unused)) +_dl_process_pt_note (struct link_map *l, 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); - return 0; } static inline int __attribute__ ((always_inline)) From patchwork Mon Jun 22 14:00:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39725 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 820D1388A833; Mon, 22 Jun 2020 14:01:01 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2053.outbound.protection.outlook.com [40.107.20.53]) by sourceware.org (Postfix) with ESMTPS id E385F388A82E for ; Mon, 22 Jun 2020 14:00:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E385F388A82E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=iYgn7j8nOcVKzNfjwSz/8jsWOtsZnZBHqMEDfi+iKLs=; b=NVIiIEvveTBoqL5MDXga8IVGqQdorvgr8SFWNylVFpAA/LRoYwP5ZyaPFVDjbHdt6lECH8SSZNXt6b/B2/5SeOszXeWUE3CUwf2I9UOuZHVqI1v4tPaCsI8i6H7AgWjwo7W+ab77lCT/DXL4vh7E+gLbGPR/BEFHh27zD+o1yxU= Received: from AM6PR04CA0066.eurprd04.prod.outlook.com (2603:10a6:20b:f0::43) by DB8PR08MB4041.eurprd08.prod.outlook.com (2603:10a6:10:ad::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:00:56 +0000 Received: from VE1EUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:f0:cafe::ca) by AM6PR04CA0066.outlook.office365.com (2603:10a6:20b:f0::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT010.mail.protection.outlook.com (10.152.18.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:00:56 +0000 Received: ("Tessian outbound f44be76249db:v59"); Mon, 22 Jun 2020 14:00:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 034a5c523539b205 X-CR-MTA-TID: 64aa7808 Received: from 525e0750f074.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 80776D1F-55BE-4EF9-A96E-68C1FFD0CBD3.1; Mon, 22 Jun 2020 14:00:50 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 525e0750f074.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:00:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bsCeVNZKk0ZBFAjq9RvI9gm8hAcQj26yltUuNBP9y2x4YF/rsjY4yNWDLRUWegdxEhaTw7P4ebHf/hBNGGV8M4Euq0dWT/xLsFW8FZybpi6R825bhmneAc/74oI9OSj9A/bs6DGytwSnFrSnI7upPDHUYA1QHJm4PyHvVhQYUgqRPekYZf3G/fki0ag7UAVuvdTH8jn+o8jp/Gv0J9q7+hy/pZIqULsgpcrqEfG5Io4B+WPs0/Uj2P6GYOVw1ySOkiHEBZfR+0LOooUXZhrZTFyp5b2VqFsClxg51bVl5TIFbdwUsEzjSL60SehzjK39pt6Rux3doNXHvDI0nCJkig== 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=iYgn7j8nOcVKzNfjwSz/8jsWOtsZnZBHqMEDfi+iKLs=; b=YrzN5LVgyqGEbLicrVDvwhG8Zz+VVyxdaMl3xfHfWngOc54Lq3Cv/78kRra1QIKj79w4qhTHyeTgX78YXxRPTIfux4XrCeGWNXio9UH3c2Pn6BHqvMesRoTumI9Cwdxtav16XQ19IppGPUR/tLgHrY4EKT3FYf4MHlIIwVWmwpDnsN97Sff70YqZUzOI7kw8StCFmQ3kwvh04uAKUknnKGPTyi0bIEY+8IqLAmdyplP7l82940IH6kMg7gyklI+eIpx4SVZX9tIeJkf9V0v5kRvtWe68WdSFhQyNzX2aqdy+cRuPnaSbC/GclhI/yzMESVgwZC+OjhAdtAbhjj8yqQ== 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=iYgn7j8nOcVKzNfjwSz/8jsWOtsZnZBHqMEDfi+iKLs=; b=NVIiIEvveTBoqL5MDXga8IVGqQdorvgr8SFWNylVFpAA/LRoYwP5ZyaPFVDjbHdt6lECH8SSZNXt6b/B2/5SeOszXeWUE3CUwf2I9UOuZHVqI1v4tPaCsI8i6H7AgWjwo7W+ab77lCT/DXL4vh7E+gLbGPR/BEFHh27zD+o1yxU= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 14:00:49 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:00:49 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 09/14] aarch64: enable BTI at runtime Date: Mon, 22 Jun 2020 15:00:43 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LNXP265CA0015.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::27) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LNXP265CA0015.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.25 via Frontend Transport; Mon, 22 Jun 2020 14:00:49 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6fa39a99-1280-4351-f89f-08d816b4af4b X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|DB8PR08MB4041: 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-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: TxyEj3mwq6+f5G7pxfZu0TEVTdzYcgdrHtqfqpMvMShXs7k1wNmG2PWjm0O0/oJFzODh/cAGUQB8LT3rZkcxPJNIIMi04ECXYnAlDsqjgq7w0ZkRYHDtF2LeW/KMloUrc1P7jzjyLJHpV4IXFTUrq74Whj7yzSUhsLVzSGbSF2YcnRbBSlmb6FSzfJ7zlqgtd1A8qtCNhwAyEKLFZxupGQ4S0qyr/Gk50cLthMygn6nvOcC0iju2M+UAnXh2dSPatBUGoWTrrBcqh30RZIlNqd0Em7IardakbE6kclQVUzk5nKrK++nQRF/GvdYBONas/NRqr3BZQaW+2O9QBgnDU7MZNMshmhzEIlmAXRnWjTnXtHYdLxJlHCBItLqKdAJ8EgeSlCGun89vScX8LUY9aFCjUwFu08ugeJOJIXOMdU9wPdlmEtIti82ie8tw7Z3Gg7VqAUpjkn8/ubs+pTqAeEBzLYPMkRUChxIPnGBZgckCV2frbQ6P9UYH1yDSrHvh+hCQdnPGcRf+VnrWMR1lXA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(4326008)(86362001)(6916009)(136400200001)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UTBhMTYytrQorzdzOwNYkbr4S4DIEh5fFEOWVtyv0cnMvUsFrONXoClQ0pqSoDFgeq8ziyJcUYM2EPGhq+x2krRA2Z+omautx1eZDlfUmXxpcU0ajPvzbAoRb0jGpgxUZi1eWtXF0Kl6VYHfgQD8/jkozhNSoMRdCeRZkL6RtCiAENnOklFd2nj4LilH8VU+Vj04LxSVqk00n0h09a+UDuvobJvniHofbF2McEEr6dH1iL5Z4l0g/rU16NUzdtXceu2dib3aQ0Oo4pOQ2x03hL5xxp5zRN/pp/JSyiJ45o+Piio7ConAU1HK5LKeN9boyl4/qDKRWQgOtG2LjA5C7xbqzcT4uZ7VcR2QfXCLRWGW5cVV0SOrvZHVgCJg/cIN9YAdsliF3RzbkyZqMrWg2ncX0oAzWD2BuPu+LdOagjq3pT6khI+B2Yn1/uHFD9qW6HyMelm6J68PW2WnnHAmD8Koy8l14HucWOO4IgpmEDs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 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: VE1EUR03FT010.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(396003)(136003)(39860400002)(376002)(346002)(46966005)(6512007)(26005)(8936002)(5660300002)(82740400003)(70206006)(8676002)(82310400002)(2906002)(356005)(86362001)(186003)(81166007)(16526019)(70586007)(69590400007)(6916009)(36756003)(47076004)(6666004)(336012)(6506007)(956004)(4326008)(44832011)(2616005)(36906005)(478600001)(316002)(6486002)(136400200001)(2004002); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: eed9ee96-23f8-40a2-fe7e-08d816b4ab32 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4tubi9fw5ZFV9rP51qJlnNRFRwwiddXARhevfhchlZG10f5Qs00FGslt7CwfJjD90xvYd7NQN1ecDvMDrM+ZNp65D5xi83s1hInlPyJ8Bd/4+qp69i+r7NFxUrunRc0EHD/yZX2k4TmSfuIQRwf25Vakd0Uxhw2of34jUJ+H6BvflIDzVQ/Qsj5Y+16onIrfmokZX84S6t4YEMEpvKQydDLzFo9Y1aQvpi9QodH3R5GELzYJaxEjmnPxFUulxubcs4Qdrt/K9F3+kuEQzzGMVl3fpzv/pJp6cXIfqZEdSEaOdMimQFb0PXGNZOrFkJhdnKkE2+9osgKf0oSMYuOlwTWqjA+HV66YTG0Qj7Hv9ia882kHoOkgn36rgNEmDi7rW3e1UJRBoX23aIWI63zUjVA9l0kSpiPcILr4ZBV5QcVbHAmCGakSXH8W6Av2V3bd3ZINeLr/NKbvykq/KkwSxHtMO8gehCXm8mfLzda1QUp7tOkX+sblYTuyEhepgVhMqk+WAYozOAdQfTCSgZirrlt7zSGAhfXu6nO+uGCCAWq37pQuqkRa4DufsWy6ZHhx X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:00:56.2283 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fa39a99-1280-4351-f89f-08d816b4af4b 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4041 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sudakshina Das Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Sudakshina Das Binaries can opt-in to using BTI via an ELF object file marking. The dynamic linker has to then mprotect the executable segments with PROT_BTI. In case of static linked executables or in case of the dynamic linker itself, PROT_BTI protection is done by the operating system. On AArch64 glibc uses PT_GNU_PROPERTY instead of PT_NOTE to check the properties of a binary because PT_NOTE can be unreliable with old linkers (old linkers just append the notes of input objects together and add them to the output without checking them for consistency which means multiple incompatible GNU property notes can be present in PT_NOTE). BTI property is handled in the loader even if glibc is not built with BTI support, so in theory user code can be BTI protected independently of glibc. In practice though user binaries are not marked with the BTI property if glibc has no support because the static linked libc objects (crt files, libc_nonshared.a) are unmarked. This patch relies on Linux userspace API that is not yet in a linux release but in v5.8-rc1 so scheduled to be in Linux 5.8. Co-authored-by: Szabolcs Nagy --- sysdeps/aarch64/Makefile | 4 ++ sysdeps/aarch64/dl-bti.c | 54 ++++++++++++++++ sysdeps/aarch64/dl-prop.h | 63 +++++++++++++++++++ sysdeps/aarch64/linkmap.h | 3 + sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h | 1 + sysdeps/unix/sysv/linux/aarch64/bits/mman.h | 31 +++++++++ .../unix/sysv/linux/aarch64/cpu-features.c | 3 + .../unix/sysv/linux/aarch64/cpu-features.h | 2 + 8 files changed, 161 insertions(+) create mode 100644 sysdeps/aarch64/dl-bti.c create mode 100644 sysdeps/aarch64/dl-prop.h create mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/mman.h diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 9cb141004d..5ae8b082b0 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -1,5 +1,9 @@ long-double-fcts = yes +ifeq ($(subdir),elf) +sysdep-dl-routines += dl-bti +endif + ifeq ($(subdir),elf) sysdep-dl-routines += tlsdesc dl-tlsdesc gen-as-const-headers += dl-link.sym diff --git a/sysdeps/aarch64/dl-bti.c b/sysdeps/aarch64/dl-bti.c new file mode 100644 index 0000000000..3c92377cc8 --- /dev/null +++ b/sysdeps/aarch64/dl-bti.c @@ -0,0 +1,54 @@ +/* AArch64 BTI functions. + Copyright (C) 2020 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +static int +enable_bti (struct link_map *map, const char *program) +{ + const ElfW(Phdr) *phdr; + unsigned prot = PROT_READ | PROT_EXEC | PROT_BTI; + + for (phdr = map->l_phdr; phdr < &map->l_phdr[map->l_phnum]; ++phdr) + if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X)) + { + ElfW(Addr) start = phdr->p_vaddr + map->l_addr; + ElfW(Addr) len = phdr->p_memsz; + if (__mprotect ((void *) start, len, prot) < 0) + { + if (program) + _dl_fatal_printf ("%s: mprotect failed to turn on BTI\n", + map->l_name); + else + _dl_signal_error (errno, map->l_name, "dlopen", + N_("mprotect failed to turn on BTI")); + } + } + 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 new file mode 100644 index 0000000000..b0785bda83 --- /dev/null +++ b/sysdeps/aarch64/dl-prop.h @@ -0,0 +1,63 @@ +/* Support for GNU properties. AArch64 version. + Copyright (C) 2018-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_PROP_H +#define _DL_PROP_H + +extern void _dl_bti_check (struct link_map *, const char *) + 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)) +_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) +{ +} + +static inline int +_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz, + void *data) +{ + if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) + { + /* Stop if the property note is ill-formed. */ + if (datasz != 4) + return 0; + + unsigned int feature_1 = *(unsigned int *) data; + if (feature_1 & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) + l->l_mach.bti = true; + + /* Stop if we processed the property note. */ + return 0; + } + /* Continue. */ + return 1; +} + +#endif /* _DL_PROP_H */ diff --git a/sysdeps/aarch64/linkmap.h b/sysdeps/aarch64/linkmap.h index 943a9ee9e4..847a03ace2 100644 --- a/sysdeps/aarch64/linkmap.h +++ b/sysdeps/aarch64/linkmap.h @@ -16,8 +16,11 @@ License along with the GNU C Library; if not, see . */ +#include + 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. */ }; diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h b/sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h index 4ee14b4208..af90d8a626 100644 --- a/sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h +++ b/sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h @@ -72,3 +72,4 @@ #define HWCAP2_BF16 (1 << 14) #define HWCAP2_DGH (1 << 15) #define HWCAP2_RNG (1 << 16) +#define HWCAP2_BTI (1 << 17) diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/mman.h b/sysdeps/unix/sysv/linux/aarch64/bits/mman.h new file mode 100644 index 0000000000..ecae046344 --- /dev/null +++ b/sysdeps/unix/sysv/linux/aarch64/bits/mman.h @@ -0,0 +1,31 @@ +/* Definitions for POSIX memory map interface. Linux/AArch64 version. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* AArch64 specific definitions, should be in sync with + arch/arm64/include/uapi/asm/mman.h. */ + +#define PROT_BTI 0x10 + +#include + +/* Include generic Linux declarations. */ +#include diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c index 896c588fee..b9ab827aca 100644 --- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c +++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c @@ -83,4 +83,7 @@ init_cpu_features (struct cpu_features *cpu_features) if ((dczid & DCZID_DZP_MASK) == 0) cpu_features->zva_size = 4 << (dczid & DCZID_BS_MASK); + + /* Check if BTI is supported. */ + cpu_features->bti = GLRO (dl_hwcap2) & HWCAP2_BTI; } diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.h b/sysdeps/unix/sysv/linux/aarch64/cpu-features.h index 1389cea1b3..a81f186ec2 100644 --- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.h +++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.h @@ -20,6 +20,7 @@ #define _CPU_FEATURES_AARCH64_H #include +#include #define MIDR_PARTNUM_SHIFT 4 #define MIDR_PARTNUM_MASK (0xfff << MIDR_PARTNUM_SHIFT) @@ -64,6 +65,7 @@ struct cpu_features { uint64_t midr_el1; unsigned zva_size; + bool bti; }; #endif /* _CPU_FEATURES_AARCH64_H */ From patchwork Mon Jun 22 14:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39726 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E3602388A82F; Mon, 22 Jun 2020 14:01:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00046.outbound.protection.outlook.com [40.107.0.46]) by sourceware.org (Postfix) with ESMTPS id 27A39388A83C for ; Mon, 22 Jun 2020 14:01:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 27A39388A83C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=Xkk70UnhwzcPDBDJqRTR+TK5gJxA5NMHZ+LDknF0r/E=; b=GW+tfOvtVZMvO7ibwcBmoUUER3XImR8n7i7lyBp7ACNpBtNa5rzVEn9R5N8vmII3rIiS1IGVnSw32E96aIsugRL1cz8+7WilrHGLo10MmcuZdVdRE2bNLjQTUlVEeosWpDrHpklL4+jCtoCCahqCed5/3MBZkFTJEy9uWGALS6k= Received: from AM6P191CA0067.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::44) by VI1PR0801MB2111.eurprd08.prod.outlook.com (2603:10a6:800:8d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:01:06 +0000 Received: from VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:7f:cafe::8b) by AM6P191CA0067.outlook.office365.com (2603:10a6:209:7f::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT038.mail.protection.outlook.com (10.152.19.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:06 +0000 Received: ("Tessian outbound 8fb20e43acb7:v59"); Mon, 22 Jun 2020 14:01:06 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fad9aaee73ca51e6 X-CR-MTA-TID: 64aa7808 Received: from aa30dbc25193.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F3FE66B0-6D6B-4B84-B70A-0F9DC6C4CA06.1; Mon, 22 Jun 2020 14:01:00 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id aa30dbc25193.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:01:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lWyNP8ertlrUgSBwKum3EjYKNvcyj44doH9ayv1BvQiCTM41A7zNhoHc/mMJGKZFRu4D5UKeIKDMU3B8+VLwkWGPiHqZqo6g31eptpvw/sq68pEJc4jMQo2Tcdyf5tUyywjiA8udEdEy7l9HsY2j6N8IoAubVsif/CByUUz4dsdqLgy5kIAzM9y/n7n90sAnKFgruFJaLXEr26o9sT2iXyp+qnjX8pxLxb2nbKKAFvwkGXe/T5hG+W23u2gnJlSoq2WjKF6IKgZzUL5H6tov9yLBFKWm9uvck+RUjtr99WASkV11JguclDwlSy7e3B384NS33/6IrEHICCPCaJBakg== 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=Xkk70UnhwzcPDBDJqRTR+TK5gJxA5NMHZ+LDknF0r/E=; b=jyrnLpia34pXoJ9cmBEOEpMPcqBV9ntgOtBVWXbegFEmEo5UxCeeNP/swkD8+HvCjuwh14g8ifT4iF0FL3rct/qFIrFeMQKlaRNAJz6Mb2IPWGBfRWchYn8FVwTW+dBnimV8gW19oJFcKm7TYqt1tyIVeJ9roBW+kpActrM/97EDUB37p+jtXm9A/pkMpAIlZnsny82CtcF29pMq8Ish+7g7Z/EiuCct4u68eqSVAPm+vWyLQc/RJO3RPUOq9VCt/tUl/xBv0n3rvdM1SsnLRlHmnCcvcYN3nPZUCr+2YBAeRRR4eEQH1Z2E82a8HPTkC0ePt4uTsKgSaZT0cb3+pw== 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=Xkk70UnhwzcPDBDJqRTR+TK5gJxA5NMHZ+LDknF0r/E=; b=GW+tfOvtVZMvO7ibwcBmoUUER3XImR8n7i7lyBp7ACNpBtNa5rzVEn9R5N8vmII3rIiS1IGVnSw32E96aIsugRL1cz8+7WilrHGLo10MmcuZdVdRE2bNLjQTUlVEeosWpDrHpklL4+jCtoCCahqCed5/3MBZkFTJEy9uWGALS6k= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4344.eurprd08.prod.outlook.com (2603:10a6:20b:74::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:00:58 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:00:58 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 10/14] aarch64: configure check for pac-ret code generation Date: Mon, 22 Jun 2020 15:00:52 +0100 Message-Id: <660c83073d49a06756a759bb511532a385e268b2.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LNXP265CA0023.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::35) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LNXP265CA0023.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Mon, 22 Jun 2020 14:00:58 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cbda2cb8-6b1f-40ee-3cdc-08d816b4b526 X-MS-TrafficTypeDiagnostic: AM6PR08MB4344:|VI1PR0801MB2111: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3276;OLM:3276; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: tsACYgHVPemyRV3ftUF6hzsqsLXdYJsDA33aZZPOoVdevZ42Cg4GaJj+5iM9biwBRvTaQhAg9k7x9rIZk7K6xxziTx7gMw+ZVrtr1KA7pzmgv5GzYsDKkKyfw2N2zD5XaCIylnFhEwpPNuGc7mPym8hXUMm+Q4lEda/BE+jI5x5RAwNioIzBOswcxi9p0FNh+5sR3yL29XAuPLFuaVq1YwSZW/90u6MwuGD9J6j/l0uJwJ62q+hWQG0bV11JgUu2Qd8sXXG+Igb0cfgkL1/dIPBn9UBWJTZYXfAye/SttyzsvCMSFdApVhEWr9wW8bXIDt0kef3LLQfABhoz/fyaoiKRqMQr482uceoHw2d5acxnLinNvnh8KVO2RDyECL8Bo/Ud5zC4t9PJzzRlSfrLHhBYhEqy/Ev++TDPIDeqlLU= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(396003)(346002)(366004)(376002)(52116002)(2616005)(69590400007)(66946007)(66556008)(26005)(66476007)(6916009)(956004)(6666004)(6506007)(2906002)(186003)(16526019)(86362001)(6486002)(44832011)(478600001)(8936002)(36756003)(316002)(5660300002)(83380400001)(6512007)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Li+ZojSrLANO/u0/NvzDcPo3DkbJBJxVTDXqmFgXb3ON/n+rEq9HxCXIJXumsEuIXPWUsS0dtmt5Vs5U1R/45BP+KovowgFPMxVK1JigXdDlBQz8wJuC1m9zdju4Ud9gnY/1xPpkkO1VELP+YAmOD/FsxNy+qcXP3kTDlCAYQFOGPCBc5n4ZBvw+Li9eURz1aYSTff2QWHjJSa7uCkCfGSCZZM9dSsjIehxbP481pxVBVWli8YUwqcQTFq18m1hsPFR3hRTeb/p0F8JcciZAirVJtnHe33tROisNDu5G1VkSqNhV7B0GpOwHf3AqfZSyJtrXnEke7lpGfLclE3kNqIWfAF0mdtTnB994w1+MBz4O9sw2i6MJoudU3EfYHG/OkmxNluhc1AcAKNHpJwph4G609e47ozr33InwHRrar5oSb4FBNXWpZd4RtijwBG1pRgBYccnEtBWJRTWKK223SVuxPmVKa5nD/RvtifTKOrDDRguxbrJS9u0QDa4PrVdJ X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4344 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: VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(376002)(396003)(39860400002)(136003)(346002)(46966005)(47076004)(478600001)(6506007)(26005)(16526019)(316002)(186003)(69590400007)(356005)(36906005)(82310400002)(8936002)(2616005)(81166007)(5660300002)(2906002)(70206006)(44832011)(82740400003)(70586007)(336012)(6512007)(6916009)(6666004)(956004)(86362001)(83380400001)(6486002)(36756003)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 9754ae84-20d2-4b3c-515b-08d816b4b091 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kQYU3Xjk6EVIYt1bFxT8HvLD7LFjpsN0QPKHv4Kvnj9OeXQ8A05VmJlmtACqph2bezF317xuN7G7NHGuQhVGqAy6GrVQCI8DjsjVL29YgFGEdlx89NKqS+9fz1+UzOvpUW/H5JJV1mfGpHkgqYqvDG79vYaozQRLB6c/pUw/DXqtMqQumW1I8/WTCbNrVEqnzh2Qkt1J/twJIZG/z7XYUcPSdH1FcnCg5l1pnmotJKBNENP61ZfF2DCnYSrLl1bOm6AEgL6j8mwoJ8eCglf9PPMpayK6D3rU8dhN0oNEcrZUw+GtIweGqmJHGI5pbvQ6YSwbXkPW1byfj8mMBsrnzgEIbTPIzxmRRaiVTExIG+1ZlUJvrBfuK5kmJvFpEGa5+WH4qkmYbBjsw2l+tUa58Caa2TDSKka8kLY1TC1aJx+9I+BZeCBIq/ug3ViryYfXIrmpEWtrnC89fnXUm/oKLA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:01:06.0902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbda2cb8-6b1f-40ee-3cdc-08d816b4b526 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2111 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Return address signing requires unwinder support, which is present in libgcc since >=gcc-7, however due to bugs the support may be broken in --- config.h.in | 3 +++ sysdeps/aarch64/configure | 39 ++++++++++++++++++++++++++++++++++++ sysdeps/aarch64/configure.ac | 21 +++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/config.h.in b/config.h.in index 67169e5d01..7921917ad2 100644 --- a/config.h.in +++ b/config.h.in @@ -112,6 +112,9 @@ /* AArch64 BTI support enabled. */ #define HAVE_AARCH64_BTI 0 +/* AArch64 PAC-RET code generation is enabled. */ +#define HAVE_AARCH64_PAC_RET 0 + /* C-SKY ABI version. */ #undef CSKYABI diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure index 70477a7fa5..5f1cdf5d9b 100644 --- a/sysdeps/aarch64/configure +++ b/sysdeps/aarch64/configure @@ -214,3 +214,42 @@ if test $libc_cv_aarch64_bti = yes; then $as_echo "#define HAVE_AARCH64_BTI 1" >>confdefs.h fi + +# Check if glibc is built with return address signing, i.e. +# if -mbranch-protection=pac-ret is on. We need this because +# pac-ret relies on unwinder support so it's not safe to use +# it in assembly code unconditionally, but there is no +# feature test macro for it in gcc. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if pac-ret is enabled" >&5 +$as_echo_n "checking if pac-ret is enabled... " >&6; } +if ${libc_cv_aarch64_pac_ret+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } \ + && { ac_try='grep -q -E '\''(hint( | )+25|paciasp)'\'' conftest.s' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_aarch64_pac_ret=yes + fi + rm -rf conftest.* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_aarch64_pac_ret" >&5 +$as_echo "$libc_cv_aarch64_pac_ret" >&6; } +if test $libc_cv_aarch64_pac_ret = yes; then + $as_echo "#define HAVE_AARCH64_PAC_RET 1" >>confdefs.h + +fi diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac index 798f494740..8248ecf2ed 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -39,3 +39,24 @@ EOF if test $libc_cv_aarch64_bti = yes; then AC_DEFINE(HAVE_AARCH64_BTI) fi + +# Check if glibc is built with return address signing, i.e. +# if -mbranch-protection=pac-ret is on. We need this because +# pac-ret relies on unwinder support so it's not safe to use +# it in assembly code unconditionally, but there is no +# feature test macro for it in gcc. +AC_CACHE_CHECK([if pac-ret is enabled], [libc_cv_aarch64_pac_ret], [dnl + cat > conftest.c < X-Patchwork-Id: 39727 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF291388B000; Mon, 22 Jun 2020 14:01:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60072.outbound.protection.outlook.com [40.107.6.72]) by sourceware.org (Postfix) with ESMTPS id EDBC9388A83C for ; Mon, 22 Jun 2020 14:01:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EDBC9388A83C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=nUtjZ8MxE/HoT2ciyvCRhauxY1gID6XJ0NF2gGk+He8=; b=4HWCIvRxFM4cpIsgvYeaHc9siVQL33dly/L4gU5eXa87o5MMIcOgOU779fDSal2SJvdbUjCVPqUqEqRIv9FUIAz74W03RXo7iCL8NNk0rRqStErSO6EHMk6+eXzPI+zCbkX4e9dBqJpF0EixScUD/DF7QFFi3L+6Hk0yca/XmBg= Received: from AM6PR04CA0058.eurprd04.prod.outlook.com (2603:10a6:20b:f0::35) by AM7PR08MB5368.eurprd08.prod.outlook.com (2603:10a6:20b:103::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 14:01:14 +0000 Received: from VE1EUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:f0:cafe::3d) by AM6PR04CA0058.outlook.office365.com (2603:10a6:20b:f0::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT010.mail.protection.outlook.com (10.152.18.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:14 +0000 Received: ("Tessian outbound f44be76249db:v59"); Mon, 22 Jun 2020 14:01:14 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 90ea780cdc376049 X-CR-MTA-TID: 64aa7808 Received: from 4faba6b12a21.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 50464197-71C3-44B7-A993-4697AFEC2A2F.1; Mon, 22 Jun 2020 14:01:09 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4faba6b12a21.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:01:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XQhyCYXuLtMxIZAdgQPJZcjZDFebaWFMce0G95P4zCo/SYDJD8TB62w+z1jA5NYlofkU20L4TGtuO0WZEkoxxh3WpCqrdPt4eT1ToNmjp7zo5pBHOgS5P0yatRV2lL3kkVyzrw94pe21QykUfkjA66qA8FeopgPDL2D6i0yxmfuCdXpadClDi3kWyZxM5McuquDyG+UIU0F+ijal6YLdwsTcUSOiOcdxheJxpvLlVfDEz0xPDr4LS2UFXbKAiWS6tlFB6s3mIk+jZqn/bIhC5+mwb1Io8QZDvezhlxUX0yTBQOZ7ihs79P73GoYMhQEJOGfd0Z0ZB0xvSYA/BuXyPw== 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=nUtjZ8MxE/HoT2ciyvCRhauxY1gID6XJ0NF2gGk+He8=; b=C6uZhtgWL6/rVSU+eWkBAHD0S+0IzhlYZ7QqVdbuDA9qxua1CYL4nrYMONhVjvzdfz02Lf9CZqjnIbY2/a/6B8rg9CKGsfV7DZ/sqgsP0QwiGjnvGqBz/rnlYngPP36X/s//635LU415aPIcwyVm8n7VQwoj9NQz4CoI+em+roYj9yJS3DhRU3bDllvepy90SaWzn3x8VYpe1KXskLEtqmAEj7wM2MddFlTvxAojhgoT6eLiWPL2b2gKIIm/rp2nYrAeRcUBRCc9e7OaTJf42kgkdis9nR0IMhR0B0syqrQepFmxjVAl6tK0ziSLVLXSGXNeflJ9to8Ioatd11pjfQ== 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=nUtjZ8MxE/HoT2ciyvCRhauxY1gID6XJ0NF2gGk+He8=; b=4HWCIvRxFM4cpIsgvYeaHc9siVQL33dly/L4gU5eXa87o5MMIcOgOU779fDSal2SJvdbUjCVPqUqEqRIv9FUIAz74W03RXo7iCL8NNk0rRqStErSO6EHMk6+eXzPI+zCbkX4e9dBqJpF0EixScUD/DF7QFFi3L+6Hk0yca/XmBg= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 14:01:08 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:01:08 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 11/14] aarch64: Add pac-ret support to assembly files Date: Mon, 22 Jun 2020 15:01:01 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LNXP123CA0003.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:d2::15) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LNXP123CA0003.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:d2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.26 via Frontend Transport; Mon, 22 Jun 2020 14:01:07 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3a62234a-54ba-4f77-a6b5-08d816b4ba40 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|AM7PR08MB5368: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: mB3YsIRUqcqtWUPyTvhTvr3jJiOu9PfjtI+pMZpxfFJdVEBJZ2Ox915omH4ScFoGx5ovObmYxCKV6QFbTKzhw9zuk5mhyOT40pXDaI/pai/QfUpO4JlK71IyYgvnPCFMaCBIAAJmF409oRNFqgUscytm2xNz99GI00WuvJh3jGtjH9FebOYEZ74eC0fEobdiOZZbvl7Fomo4wVxCfybU5nkTaFw6JiOfh2lhpC/mcya2hNzcOuv7haSng3RNT7QUoeXdUimqhO8Rz21Svp90cYHLxR2qN78+TY/sCDjIYE/eSJNo8N8x38WN1K3Bl7lJKzLyKLDygccWl2eTuDzYVdVvHMS4HEuNRgh0LJ6gYQ87O5gBlEXdcDLE4Pd4JucbUrWV9D1kX505cY0LISXGj+rj0rV67t1JVuyeEErB3dc= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(83380400001)(86362001)(6916009)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dBDNp9mcuFzn9bchuRBzG/oCULPJ9F7DV9FK3gqzkiaPNCM69rJEiKnaeyv85dhR3zyje/bE5XBR2WxIpO+ECHAJxTZQsjqPEUyxftt+LOA0lgJs0NvW2cRgnhF4wklrdh7y2jae47UaMdFd1r8QuzA5WOPPDxZRqkpebD62q6Cvroj3Q+c9c6vWYvUiQ2PG3A6yLzQKJMyv2yOL5AWD5Y7m/qlVtR8eRBtIUa6zA2T3PgBJ8D71H4xeqGQwvL5YIUjmH4c9DH5Y3NMyReCsb2tBlzlGIKz5PW3f0R/GbsWY2jgSSO+KC7UAV4Qr/iBKtMu+HE1rLUUIROhyk4ExQ0lWU355AY7MPWy4/cm0lntaRdwwVZJuCETk5gfFkN8oAeTMomC/+DCoY1xdrlL6ZxP8T/6YQ1W/k2R1qjiBeDYPv+pDzc7hS7K7MLfO5QcUkz2UbGOgsFc0NhfXz89P62jjJe18sTlnHzR7+2f5AHw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 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: VE1EUR03FT010.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(39860400002)(396003)(376002)(136003)(346002)(46966005)(36906005)(70586007)(356005)(81166007)(336012)(5660300002)(478600001)(82740400003)(70206006)(6916009)(2616005)(44832011)(69590400007)(956004)(47076004)(8936002)(36756003)(86362001)(8676002)(26005)(6666004)(6486002)(6506007)(83380400001)(16526019)(6512007)(186003)(316002)(2906002)(82310400002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 5281d195-1b1d-4017-da99-08d816b4b60b X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fqgOaFbTclnquAGU89uj5Xr+4lK4FNQ6zuKehD/e1Bi3CJAHn8XmFJsJTluIrFhdXnnPlzISLDDSHnU+vCw/jqTT/xgNI88F/MCvPtJbNTcYxXRR4jNYohAKZbgR3xSWZGRdwNTAKLNqL7AHlkM3sjk5B8Yv1VTv/AP/076n5ECin6vKnHbtMPZ69Z0HUQpzuxmDjIfL+PhInIxc3tpNYKTbMZ+GLhYqGBiDNXmvp/vte8rqYko18Y73+8/J6tNfkGBK5WHnTnLv/4ozC5VH0D6LddEfMAHvI0a8eu3EDTdUVvCxaiSnmqPcm+Im69mA0lZj4mqtHOcnRrpc2tnIhCu87ZAnN4JXagORYYxxDlgPWrsJ4MBxQT5V4saaPHKcq8G3m4VZUt/EMSrzKzSPCvFO7k/HywcWCNTMpYIA+WVccnxNVg9+aP3o+ix2lxlivxR3GglriCvzz/gVGwlqDg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:01:14.6520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a62234a-54ba-4f77-a6b5-08d816b4ba40 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5368 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Use return address signing in assembly files for functions that save LR when pac-ret is enabled in the compiler. The GNU property note for PAC-RET is not meaningful to the dynamic linker so it is not strictly required, but it may be used to track the security property of binaries. (The PAC-RET property is only set if BTI is set too because BTI implies working GNU property support.) Reviewed-by: Adhemerval Zanella --- sysdeps/aarch64/crti.S | 8 ++++++++ sysdeps/aarch64/crtn.S | 6 ++++++ sysdeps/aarch64/dl-tlsdesc.S | 8 ++++++++ sysdeps/aarch64/dl-trampoline.S | 18 ++++++++++++++++++ sysdeps/aarch64/sysdep.h | 8 +++++++- 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/sysdeps/aarch64/crti.S b/sysdeps/aarch64/crti.S index c346bcad72..c486e9ca44 100644 --- a/sysdeps/aarch64/crti.S +++ b/sysdeps/aarch64/crti.S @@ -75,7 +75,11 @@ call_weak_fn: .hidden _init .type _init, %function _init: +#if HAVE_AARCH64_PAC_RET + PACIASP +#else BTI_C +#endif stp x29, x30, [sp, -16]! mov x29, sp #if PREINIT_FUNCTION_WEAK @@ -90,6 +94,10 @@ _init: .hidden _fini .type _fini, %function _fini: +#if HAVE_AARCH64_PAC_RET + PACIASP +#else BTI_C +#endif stp x29, x30, [sp, -16]! mov x29, sp diff --git a/sysdeps/aarch64/crtn.S b/sysdeps/aarch64/crtn.S index 0c1ef112c2..d21c21c203 100644 --- a/sysdeps/aarch64/crtn.S +++ b/sysdeps/aarch64/crtn.S @@ -41,8 +41,14 @@ .section .init,"ax",%progbits ldp x29, x30, [sp], 16 +#if HAVE_AARCH64_PAC_RET + AUTIASP +#endif RET .section .fini,"ax",%progbits ldp x29, x30, [sp], 16 +#if HAVE_AARCH64_PAC_RET + AUTIASP +#endif RET diff --git a/sysdeps/aarch64/dl-tlsdesc.S b/sysdeps/aarch64/dl-tlsdesc.S index 9d96c8632a..db8a064322 100644 --- a/sysdeps/aarch64/dl-tlsdesc.S +++ b/sysdeps/aarch64/dl-tlsdesc.S @@ -183,6 +183,10 @@ _dl_tlsdesc_dynamic: callee will trash. */ /* Save the remaining registers that we must treat as caller save. */ +# if HAVE_AARCH64_PAC_RET + PACIASP + cfi_window_save +# endif # define NSAVEXREGPAIRS 8 stp x29, x30, [sp,#-16*NSAVEXREGPAIRS]! cfi_adjust_cfa_offset (16*NSAVEXREGPAIRS) @@ -233,6 +237,10 @@ _dl_tlsdesc_dynamic: cfi_adjust_cfa_offset (-16*NSAVEXREGPAIRS) cfi_restore (x29) cfi_restore (x30) +# if HAVE_AARCH64_PAC_RET + AUTIASP + cfi_window_save +# endif b 1b cfi_endproc .size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic diff --git a/sysdeps/aarch64/dl-trampoline.S b/sysdeps/aarch64/dl-trampoline.S index 2cbfa81434..794876fffa 100644 --- a/sysdeps/aarch64/dl-trampoline.S +++ b/sysdeps/aarch64/dl-trampoline.S @@ -127,7 +127,12 @@ _dl_runtime_resolve: cfi_startproc .align 2 _dl_runtime_profile: +# if HAVE_AARCH64_PAC_RET + PACIASP + cfi_window_save +# else BTI_C +# endif /* AArch64 we get called with: ip0 &PLTGOT[2] ip1 temp(dl resolver entry point) @@ -239,8 +244,17 @@ _dl_runtime_profile: cfi_restore(x29) cfi_restore(x30) +# if HAVE_AARCH64_PAC_RET + add sp, sp, SF_SIZE + cfi_adjust_cfa_offset (-SF_SIZE) + AUTIASP + cfi_window_save + add sp, sp, 16 + cfi_adjust_cfa_offset (-16) +# else add sp, sp, SF_SIZE + 16 cfi_adjust_cfa_offset (- SF_SIZE - 16) +# endif /* Jump to the newly found address. */ br ip0 @@ -287,6 +301,10 @@ _dl_runtime_profile: /* LR from within La_aarch64_reg */ ldr lr, [x29, #OFFSET_RG + DL_OFFSET_RG_LR] cfi_restore(lr) +# if HAVE_AARCH64_PAC_RET + /* Note: LR restored from La_aarch64_reg has no PAC. */ + cfi_window_save +# endif mov sp, x29 cfi_def_cfa_register (sp) ldr x29, [x29, #0] diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h index 4664329d3a..500c272745 100644 --- a/sysdeps/aarch64/sysdep.h +++ b/sysdeps/aarch64/sysdep.h @@ -45,6 +45,10 @@ #define BTI_C hint 34 #define BTI_J hint 36 +/* Return address signing support (pac-ret). */ +#define PACIASP hint 25 +#define AUTIASP hint 29 + /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */ #define FEATURE_1_AND 0xc0000000 #define FEATURE_1_BTI 1 @@ -66,7 +70,9 @@ /* Add GNU property note with the supported features to all asm code where sysdep.h is included. */ -#if HAVE_AARCH64_BTI +#if HAVE_AARCH64_BTI && HAVE_AARCH64_PAC_RET +GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC) +#elif HAVE_AARCH64_BTI GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI) #endif From patchwork Mon Jun 22 14:01:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39728 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 169B8388B001; Mon, 22 Jun 2020 14:01:29 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2062.outbound.protection.outlook.com [40.107.20.62]) by sourceware.org (Postfix) with ESMTPS id 102B1388A83C for ; Mon, 22 Jun 2020 14:01:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 102B1388A83C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=M64pUNzJjcK8D+TvA5MCOPT0fEr/+F/yH2pckFj+PRw=; b=urKY5fjabJOFfEmegkfuhhmIHt1cAfqj8lRKgixm0JSLNrcgC9BLVFCpzlQLrqYaAuTox6C74araWizX+mi9d4Ncm3gQYWGSltEuyPGbhn3US/aH7ZsGJa2sWzooIQgDzeg5h57SSsDJpoOsvlY7nvr/3XhbkuA/UdiAQOidlEY= Received: from DB6PR1001CA0003.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::13) by AM0PR08MB3874.eurprd08.prod.outlook.com (2603:10a6:208:108::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:01:23 +0000 Received: from DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b7:cafe::ec) by DB6PR1001CA0003.outlook.office365.com (2603:10a6:4:b7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT020.mail.protection.outlook.com (10.152.20.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:23 +0000 Received: ("Tessian outbound 2ba684f51d22:v59"); Mon, 22 Jun 2020 14:01:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 914e5a0eaffcf64f X-CR-MTA-TID: 64aa7808 Received: from fa0dbc8eb788.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 140397E6-7D28-4850-A398-84047264318E.1; Mon, 22 Jun 2020 14:01:18 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fa0dbc8eb788.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:01:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jj/WQPClJjSkavbHYXS0hTs5Ib7ZJ91Byq8LdQyqbVNdhagorjIiOAsqEp82NPts7nAtnbIHHTlDCO4V+0rQEHfP+pBc5z4XMmjA/65Faehnin+xRO0a3FZFayGF2i6XZhkExd9PV6eWY0rzFbPgeh/SWFj45fhxow1aEALTK/FnRnf+hjOA+mtiawQAxYnSyoLeXAKgt6wGkdMDjHpUOxqcpChEifnYexpQOVmoHsniWnuLWh26HQo5YVuSLuui8Zksz8z0KpnLob+sxsNq5YslcY3QXEKQPrqTe7gexRh05A5Ws05umbqyntEp/Kn3GUFfrhV+H2O5yRrFzen6qw== 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=M64pUNzJjcK8D+TvA5MCOPT0fEr/+F/yH2pckFj+PRw=; b=S2U8mJVT2gTf/eZw/OXRdOJY4uFSdrwQreXmtovgpZQwbfLs+9r7VAT3FmcYvA65OasDZSaZxBja9/j8IMW3tFew8M5GuVwDWjxUZ+1Yjup80OtlqeyWdypz2eqc+ZAXmQUTm9cQU+aUx7mRpKDdzQjL1/tEjR/s68TCuxjJo4EqyQq+OjlJpbm2hQUVS0f4rUAO72qhxpbZuVAWVpXnP6k72GjEF7scVVFP34mSaj+gpq0yolFRHjeweaScuGUmXr6KGUYgMf6Yf6usJxrx4XWRVlhv0afwiUuwy8sj1zYUs7+z0rAlPYAmrk8RGhelmLhorGnvTLGnejV32Zp2XA== 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=M64pUNzJjcK8D+TvA5MCOPT0fEr/+F/yH2pckFj+PRw=; b=urKY5fjabJOFfEmegkfuhhmIHt1cAfqj8lRKgixm0JSLNrcgC9BLVFCpzlQLrqYaAuTox6C74araWizX+mi9d4Ncm3gQYWGSltEuyPGbhn3US/aH7ZsGJa2sWzooIQgDzeg5h57SSsDJpoOsvlY7nvr/3XhbkuA/UdiAQOidlEY= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 14:01:17 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:01:17 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 12/14] aarch64: fix pac-ret support in _mcount Date: Mon, 22 Jun 2020 15:01:10 +0100 Message-Id: <8f62ca73284bb85ad0b7a50dfa5a9ecae27bdc0b.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO3P265CA0009.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:bb::14) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LO3P265CA0009.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:bb::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:16 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 403db745-e4c8-4077-e7a2-08d816b4bf88 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|AM0PR08MB3874: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 2t3jIFqS1CQ08nd9/ay5l1RncHZ8JJzVao8Hm6dcnhsDWCJ7Oa/lD6S2Ul+iUiJ36p7hPXrg0OvOBf8et+PnRIynV7tjW1b1xroMbhqaeyleVqeHBk9yNZI1Y/WWbdCszTDvEmLz3J/3wH1EPHn4gxl0QLfii2oPlYlLMU9h5DmenHNK3U2ccjCZeTaYSvyYEKUvt4E+uDUOBlVFy3mXAGNGxNZC9vhdG7INpzIoEvGwUrP8NALFfv2IFKLnIjvz/r7SE3jPTEc8TPrkBN13x2RiRZcMFqa5WEu5pTeURmfV1eDD2htim8owrEU8hb8w/1ocZgMDD4B38OfuFNMh2S6Z9pv7+wzv97seHinLBHmNqPdKSUjDZAjbP3gvuqAGN4kCHvdwxp9oyXk/ESl3p2cLl8Ti4Wm3usqzDPpSc/g= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(83380400001)(86362001)(6916009)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: L+g6ZLE5RgjOEKenluTLLK9Gs0xsL5Slsv+zHKZTte9HQh5qxsv/lMFKgUqAJBt62fXqSmTZWrOpmJ4tNovWYvvEY5dwgA64W7dYNpIjOMj3R4LJ1PRPlguQ1kzdppHNYKCRbIZb15v95OPGJfbu2iwq2l7rTDSSX2Zyp2n65L66zkh3cGFNK1goADusKhEFGkHXwdnxECKWHqZmXtiaeQrjFlUV3htmsCYsjxQI5IK8UwiAda4+2AF5j322qjLHtEstlx5vlXqM3Y/TzLlBvc8eRyaA1gw3RJY6VFaClyKaZIcw30vC+nLfKfOjZMtpYIHIGeg+35RGOBdoFWZfY6s1SkUtKnuBqSI82/1P26RFaFHpDUIkNb2RQWTsFLjC4sWvVFPUbFx2vuwk1GtRNF+WKVGr7SjDVMm/6rDMwbCnf/BiU8QrpDDOR5d9ty1iSCyzrSwPAIWKKamLSzZh1g691z8WCI0LPJ909wPFUqc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 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: DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(396003)(136003)(39860400002)(376002)(346002)(46966005)(82310400002)(6666004)(86362001)(186003)(8936002)(16526019)(336012)(81166007)(5660300002)(70206006)(478600001)(70586007)(356005)(44832011)(6506007)(83380400001)(82740400003)(26005)(36756003)(6512007)(956004)(2616005)(69590400007)(316002)(6916009)(8676002)(2906002)(47076004)(6486002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 249242bd-0947-4014-647b-08d816b4bb7d X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 71pVfhioCd/x46HzJM+RAsS/w/gAKQNGpr7klsSnCSQUUpuYnNR3Lb8Gi0DrGpPdWB33wT+Pr8SdO7XngBVs0r2gKTRkMprOKed6TKVJEzbLBe0d9IEk8qooeKyZiCaVTpfoR/+6L+4DuzPT6aOg5ZYNMXI1v+wGURj2LYg2Je74pKKvWriMjLF6oygnMI6RcahgL4hotIAMr92o5MND3ANp2+j2bqDU8eqLlrO1GhC8tLA7sKsun7MqcUid4vZE9GUr7k+t20wgJuZc/YOLVi2Tor/Ak2L9yYsqOkNYdyAgR8xXdtPuWeUFGORhiDLhKXgQBF3zf4ylmcLUaNdz5we2iSF9WmH92G3NS276ZIczAprvu4SGUsJPSSgmk7nWYp5/UiUWM1t6XvLvYhbly1IQ+1yJ/qNP7QuGXT5ZH/rINA6hB0toNnTBoxt0MGpZgzWfU1b6TDMtTSNBGDzvJQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:01:23.6200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 403db745-e4c8-4077-e7a2-08d816b4bf88 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3874 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Currently gcc -pg -mbranch-protection=pac-ret passes signed return address to _mcount, so _mcount now has to always strip pac from the frompc since that's from user code that may be built with pac-ret. This is gcc PR target/94791: signed pointers should not escape and get passed across extern call boundaries, since that's an ABI break, but because existing gcc has this issue we work it around in glibc until that is resolved. This is compatible with a fixed gcc and it is a nop on systems without PAuth support. The bug was introduced in gcc-7 with -msign-return-address=non-leaf|all support which in gcc-9 got renamed to -mbranch-protection=pac-ret|pac-ret+leaf|standard. strip_pac uses inline asm instead of __builtin_aarch64_xpaclri since that is not a documented api and not available in all supported gccs. --- sysdeps/aarch64/machine-gmon.h | 3 ++- sysdeps/aarch64/sysdep.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sysdeps/aarch64/machine-gmon.h b/sysdeps/aarch64/machine-gmon.h index 730a23b781..a687298b1c 100644 --- a/sysdeps/aarch64/machine-gmon.h +++ b/sysdeps/aarch64/machine-gmon.h @@ -27,8 +27,9 @@ static void mcount_internal (u_long frompc, u_long selfpc); #define _MCOUNT_DECL(frompc, selfpc) \ static inline void mcount_internal (u_long frompc, u_long selfpc) +/* Note: strip_pac is needed for frompc because of gcc PR target/94791. */ #define MCOUNT \ void __mcount (void *frompc) \ { \ - mcount_internal ((u_long) frompc, (u_long) RETURN_ADDRESS (0)); \ + mcount_internal ((u_long) strip_pac (frompc), (u_long) RETURN_ADDRESS (0)); \ } diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h index 500c272745..2879aeaa5c 100644 --- a/sysdeps/aarch64/sysdep.h +++ b/sysdeps/aarch64/sysdep.h @@ -35,6 +35,17 @@ #define PTR_SIZE (1< X-Patchwork-Id: 39729 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8923D388B00B; Mon, 22 Jun 2020 14:01:36 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80070.outbound.protection.outlook.com [40.107.8.70]) by sourceware.org (Postfix) with ESMTPS id 5AF6D388A82E for ; Mon, 22 Jun 2020 14:01:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5AF6D388A82E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=OrWIdejFRvcSzaJ59gNmXkyaenI0h4cQ+xf+ZbXTUZQ=; b=t9L3DlopnRXhUgopBQt5H6XFJPWRkzl6MMmvd08XCgOh2427D/AtQm8oMKrLOfdkNu6xvse3us/DvhYu/OavgzRaciWIxpSC00bSSqFJoMU6GpjDxlVKrZFH2genUi/NC4q6ZRT42PWZpDRremrgqhQU/hi5unpcpUsE8bCp53A= Received: from DB6P192CA0002.EURP192.PROD.OUTLOOK.COM (2603:10a6:4:b8::12) by DB6PR0802MB2439.eurprd08.prod.outlook.com (2603:10a6:4:a0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.24; Mon, 22 Jun 2020 14:01:32 +0000 Received: from DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b8:cafe::d3) by DB6P192CA0002.outlook.office365.com (2603:10a6:4:b8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Mon, 22 Jun 2020 14:01:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT041.mail.protection.outlook.com (10.152.21.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:32 +0000 Received: ("Tessian outbound 147ff5d152c1:v59"); Mon, 22 Jun 2020 14:01:32 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6d07aa717a7ebbbf X-CR-MTA-TID: 64aa7808 Received: from 6b8e86a340a2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0BED76CC-6561-41EC-9AFB-53554F37E250.1; Mon, 22 Jun 2020 14:01:27 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6b8e86a340a2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:01:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P1qO5UCSdY7lujoSwGDiQLMKVAoTTRz8FeH9et6Rsoxa3IZlXDevrslBQkRe+QYUDDPm13dX031x6sEUs7k/k9YN15sAXoVxnEUwC4pqzzBxMxjYX1rvkylY/AKj1q9ZGkPS3kipkox5anzv587HtsWX/1KPa5wxGYFyxaXADKkdgN0ulPN6r+yJihzt/o8jBfYz07dW+7cy8YFvooBKZXESfm0S+DUGbDCYYz/V0r1GW76DLJrCIUUjkD7ymMRFLNlmaj7rPMyRBHMp79VGAHst/mLXx6NtK9p9yyNnMwVYbI6TKJfJdRCLvb1o34NufZ5R+CSdXKN+5Ae+qcTNQg== 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=OrWIdejFRvcSzaJ59gNmXkyaenI0h4cQ+xf+ZbXTUZQ=; b=hlj1Pa1rkxZOzvbDPaTBZ4xCHaxKTR63KuuF97WH/jI3PEpZp4AEcjGfJ8Rcy2/+1wkhdVpjBst6Mkjw8lGuPugxHDQrHeBx5sDg85/sHLWk6UQCmDmIjRpDTuZOfMfUxLmGOsehYFAxEeYZqMQUBPGnclqF9/1MxxLROx2mSNGHtL/ScAxtq+6nnwsOCrGI+trIskrrUKa4vCd5zudYhLsXSy3y4VHxJQKedN+E5YgjxSt2bPT9NuLx0CryfZfolYmbyjd0m9mt9moyTARrg2SE0AhZ+VpD66YeHE74SaEEwxfTKt5mFSzD1IXlT0RnUJJhjl89wMH8pkzP5ayD1A== 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=OrWIdejFRvcSzaJ59gNmXkyaenI0h4cQ+xf+ZbXTUZQ=; b=t9L3DlopnRXhUgopBQt5H6XFJPWRkzl6MMmvd08XCgOh2427D/AtQm8oMKrLOfdkNu6xvse3us/DvhYu/OavgzRaciWIxpSC00bSSqFJoMU6GpjDxlVKrZFH2genUi/NC4q6ZRT42PWZpDRremrgqhQU/hi5unpcpUsE8bCp53A= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB3640.eurprd08.prod.outlook.com (2603:10a6:20b:4c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:01:26 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:01:26 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 13/14] aarch64: redefine RETURN_ADDRESS to strip PAC Date: Mon, 22 Jun 2020 15:01:20 +0100 Message-Id: <6d42e5c2203cd7f8a9c0de04c12bb96fe09e260e.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0473.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::29) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LO2P265CA0473.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:25 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0b86f9bb-f443-4047-b2df-08d816b4c4ce X-MS-TrafficTypeDiagnostic: AM6PR08MB3640:|DB6PR0802MB2439: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: IMv+Mg7obEtsq/yjCrY1wBxhaZAcpcEs9+T3EaSwARbPdC1pqUJYQp7STOamEZeIR4+0QCdK2W6rvJxSnCqcbO4WqR9Mehb3LxlerfT2dngo6zbYJfK+yu7amFm29TSdwxy2BF/ThiYLN2dEjOrFMbIfCnhLNsz5JLh3BgDE+3kdl98MY0GZ2zVrvATgs15c+jjGMm93CAYM7lSEWo2M+YgJ0NpEf0pfSH7FOaguYnOLwDGVX2FJ2ez5YWEu3K/N8Ens4tRDpYiRadW/JeSo29JYuAHMEazymeQxd1D+BKpGZBIJDw/Nma3haHSi4CNP7Fns8ngkMwGS8twJcS3dD/yR4rghpMbNa4rKcEL7/ytEsMmY9IUwkQUJuAI/9sE49zPuZJd4j8fSQqGUxETDCIam2nL22xKmzHcrgv/GS9g= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(376002)(136003)(39860400002)(396003)(366004)(86362001)(44832011)(16526019)(478600001)(186003)(316002)(6506007)(52116002)(6916009)(26005)(2616005)(956004)(8936002)(6486002)(5660300002)(6512007)(83380400001)(66476007)(6666004)(36756003)(2906002)(8676002)(66946007)(66556008)(69590400007)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HwRyF6r0Me7T2vhgLrQaJxAhb01jqBMa7FLX6EXehzuoNgIAb4ozqb83KbAnr9TOTJ6S4XtjPwPFwFw+LbwqBdpVg22MrSyp97gkSDBfGzBwayH9NDW4S0Pc0zgao/pe9wfBGHYuFQyKh0BColnn5aL86Y+YNKPe57S3/VMfJR9hhYDWl9OBVijnWQQc1VF0sF6fak7vEc+sWASLDd374Xky9wf1eQ/LoDqpTdnW+ZnVW+l5nVcQGK6pzoX/jnnfx8fVCOQdSsgIS1ni24jtuFxaGqYGqd1HNVb7Jd16tnpJPTpNKc+PvndfI0q3uFcQv8O0lGBrMar+Y1IkuAMSdcj8TL2CQWSRB4Te7W/9Uk05K2Hur8o5noAtLpJc1r3ijK6Bx4T4EhJAbUuVbnjny1Han8+OLFVpLj4WUPRZqinzJBTCf31Q/orZCeuZPvYXEX999ZExrEECg5MJSj/vbqHw4LCFXNwgKPlvHCOkO68= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3640 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: DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(346002)(376002)(39860400002)(136003)(396003)(46966005)(26005)(6486002)(5660300002)(6512007)(6916009)(47076004)(356005)(69590400007)(82740400003)(8936002)(82310400002)(83380400001)(86362001)(8676002)(81166007)(44832011)(2616005)(6506007)(336012)(956004)(316002)(70586007)(70206006)(2906002)(36756003)(478600001)(6666004)(186003)(16526019)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: ea2877db-4c40-490a-137b-08d816b4c0cd X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GYEWLJWTdqkChpZWgvtihCtDSYGWSehUKzv0i1pSBOUXwfRQHgOu3GKBsalhmevTgbiMBPUcro3BNs8+D7ryvVrZZkn86D1p1npktAvShrBCMTbtwFfc0IOGjOgfBBsuvjbjx6VwX1TDMbVzp6HNDWxFLWsD0Q0Q95+43qbNtargrigh/N0N0GMNbh3G5wx7eNcWg3Nd9YKJTLYlAE8qbHkuo4v0TdQ+n0B0WpoVvWGJm4okt46Jjdp2fqog+QePYTwUfYIdI0MoCotSpxHOaYWTXpX16CAPY/evN07+qgfmpjaYVqvBs3XXv9VFYmI13bQZ9l2suSu2OuH41wAfnW92CK1Gx+NaN5mqbZV7bFdOxfdxN82vCAg/Mtqfz0azzl2KI/rtsS4czJiZPWpBM8gADoaVlERiiUS1CNv+CxXq1VE2xpKmMtdAOK2sAijhTwprUfQOAnBak63BMEk1ow== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:01:32.4650 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b86f9bb-f443-4047-b2df-08d816b4c4ce 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2439 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" RETURN_ADDRESS is used at several places in glibc to mean a valid code address of the call site, but with pac-ret it may contain a pointer authentication code (PAC), so its definition is adjusted. This is gcc PR target/95891: __builtin_return_address should not expose signed pointers to user code where it can cause ABI issues. In glibc RETURN_ADDRESS is only changed if it is built with pac-ret. There is no detection for the specific gcc issue because it is hard to test and the additional xpac does not cause problems. --- sysdeps/aarch64/sysdep.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h index 2879aeaa5c..593bdd35a2 100644 --- a/sysdeps/aarch64/sysdep.h +++ b/sysdeps/aarch64/sysdep.h @@ -44,6 +44,13 @@ strip_pac (void *p) asm ("hint 7 // xpaclri" : "+r"(ra)); return ra; } + +/* This is needed when glibc is built with -mbranch-protection=pac-ret + with a gcc that is affected by PR target/95891. */ +# if HAVE_AARCH64_PAC_RET +# undef RETURN_ADDRESS +# define RETURN_ADDRESS(n) strip_pac (__builtin_return_address (n)) +# endif #endif #ifdef __ASSEMBLER__ From patchwork Mon Jun 22 14:01:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39730 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55119388B010; Mon, 22 Jun 2020 14:01:51 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2069.outbound.protection.outlook.com [40.107.21.69]) by sourceware.org (Postfix) with ESMTPS id 80089388A83C for ; Mon, 22 Jun 2020 14:01:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 80089388A83C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com 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=yq0v/b67DAmzT3wW9nqHkM+lyXkY1c4Qgq/9O62XasU=; b=nVEmpPVNI0SFXTTYyoOXNayiniiq3eW4Xug1i+a0sndKpvSzbO2y5TEeaWn2HillxJ1nwpetKh2jlkQ0KYnbc/fzIo+eUVQhkVR3Z3ODNjpId+kctrqM5NhlXiV8euUT7aSbSIXK1CWUqJDBtd7RyUajXsDQhW8CrnlXfiEL3Dk= Received: from AM5PR04CA0004.eurprd04.prod.outlook.com (2603:10a6:206:1::17) by VI1PR0801MB1981.eurprd08.prod.outlook.com (2603:10a6:800:89::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:01:46 +0000 Received: from AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::6d) by AM5PR04CA0004.outlook.office365.com (2603:10a6:206:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Mon, 22 Jun 2020 14:01:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT062.mail.protection.outlook.com (10.152.17.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:46 +0000 Received: ("Tessian outbound 839770a6d413:v59"); Mon, 22 Jun 2020 14:01:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1589e4aae0b1b46a X-CR-MTA-TID: 64aa7808 Received: from 421e802de85e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CEA3430C-3C38-494A-AAA2-A9627BDE9344.1; Mon, 22 Jun 2020 14:01:41 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 421e802de85e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:01:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iq4bBqRvcYuaLWsOymm4ihSNxYWrTPm26mBtwXf5+VPk9wTY2tagsls0KmWa/oVHsF046EFmD+0ZDB5XhpQYGKNjcsi2dOWDcb6C/thOi/bydxWtifAlQzggWcO8K0gA9vyf21LCSulZoH5PZxbwa3a/Y50WxvCYwoSPT2LnTQpsA7MkfahG5C/Imx3VSlGb//pn8pOaM0YvGjJ7TaavJjG8sIesb+xb7o91yyZBPn4YqkP+8ftsfLI7j27e9CdyU+zVkprgvFvTBhAZQeqitJ2XAvW3j99abci4lf2PwB0frogvCxWRx4Ustc3FqfVomoEoqw+59zL87oWP/GmeQA== 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=yq0v/b67DAmzT3wW9nqHkM+lyXkY1c4Qgq/9O62XasU=; b=cEOg0ArSrlRaicQJsVpMIo3y0lO391W+csAkG8hR3y2QOf3Q/k65Fry49VmWNSEsH86AiKMgTqQgUcL4lVjgcNzRzrzqIh6JnaIe2+7EvX0BsYMYQ++3Xh5BxeE3/5ldhdg4kOlmPGpGhXy1tgXrOSp7MVknfpzshHoe9UnN8vtJ0Knt2XHojSNjpo4CeUNl2BWiwOpGE96VF5L6zUukxdj0RZVP/Xf1/GTtq8lZTaxhKL0OB0vMuj2Av/Rgohux6o7ml77ywDmKowDeVyupiQkcUWkYgood7Pr+HjG1m/bpzvByWZNb7wA8J2IvBAm78IfaklYYSQWeuvL27jQ9rw== 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=yq0v/b67DAmzT3wW9nqHkM+lyXkY1c4Qgq/9O62XasU=; b=nVEmpPVNI0SFXTTYyoOXNayiniiq3eW4Xug1i+a0sndKpvSzbO2y5TEeaWn2HillxJ1nwpetKh2jlkQ0KYnbc/fzIo+eUVQhkVR3Z3ODNjpId+kctrqM5NhlXiV8euUT7aSbSIXK1CWUqJDBtd7RyUajXsDQhW8CrnlXfiEL3Dk= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB3640.eurprd08.prod.outlook.com (2603:10a6:20b:4c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:01:40 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:01:40 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 14/14] aarch64: add NEWS entry about branch protection support Date: Mon, 22 Jun 2020 15:01:28 +0100 Message-Id: <27ba4dcee8ae03c0634094dcea26bf1278804982.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN4PR0501CA0061.namprd05.prod.outlook.com (2603:10b6:803:41::38) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by SN4PR0501CA0061.namprd05.prod.outlook.com (2603:10b6:803:41::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.13 via Frontend Transport; Mon, 22 Jun 2020 14:01:38 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 873594c2-b972-449d-9ed2-08d816b4cd3d X-MS-TrafficTypeDiagnostic: AM6PR08MB3640:|VI1PR0801MB1981: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: TGt3sCDrM1YPdzHyvn65a02sEe8w0gkjpS7GMJk4Em87+bnjayl7Vu9JT9uS/RkHqm9ic77UKawDWryhE2VnP5ZYQXQE45pXVwlCPv9XEntqujMgeutXF75+t011YqQFLbMHnAaLVkKfXnxhsCk4XecwQhYNy0VditVaLFTRWaZIw5uuqemfmc9K+NF+pE1ESN0LMldSlqyQxmldDK9arNqit8TBK57PPQ6+KraKTXqvrYCpPD7vWkyCuQKkfHfnrIzNJS8+pN5j/v12LQi5Va8WenQYiUmpy61k/NWCyOXmgTUJAoE55IBgEQBXkqSOpbn6b4lH5CD5n4OXUPbYw4XOWxux3wtNdx5FeEcODEbj9PQeaFlT88yS6UiNBFxEo6fVOlxJwJ78w/3X6ecehAlk86R8ez/AzCHEFYc/TsY= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(376002)(136003)(39860400002)(396003)(366004)(86362001)(44832011)(16526019)(478600001)(186003)(316002)(6506007)(52116002)(6916009)(26005)(2616005)(956004)(8936002)(6486002)(5660300002)(6512007)(83380400001)(66476007)(6666004)(36756003)(2906002)(8676002)(66946007)(66556008)(69590400007)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 44OOT2tCoFSXLsWzthoaOSjRf7MPhFnqf0/AW8QyuEMSPo7oUBXcF8MDsw4uNEek7eO6hmrA+CL5JX3NokaLnZEWEt6Yb7U2UtGNGS0Xq6h6RESZGxch+NVQj3PkwBDrCYX6N4TSkGi5wdL1ocKPAarzd2eSTPZdNrImu4ear3aPEl6Vtr5k1NBKDWsibKhqE6EfxiI1przuOcGmi1yvzcW7kfH7gYaIDqjFbJ5yirJe/B4PuFu3yXgSvak/jd/IuNSK19oDQrv/zN7eZe0Mzii6XRK1bY4xSkMQ5Xeu7pP5yCEzRtW+50/PxYBmKR22Yh8okHy2R+jUh9O+13k4hAK2PSdr6l6mWEn8s4891Hjg3iYXaWk2u5ukO2Razx8vslqnoxFmOEDl3tzUENMY/UIpi/Npwrk6NtEKP8aFVr+nNlHUEZQtNZLgEw3F30gC8HC503+47VkCVwDyj4gDMY+trLIUujRoO6W4Haw5pns= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3640 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: AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(376002)(136003)(346002)(39860400002)(396003)(46966005)(6666004)(356005)(82310400002)(26005)(6506007)(6916009)(8676002)(316002)(70586007)(336012)(478600001)(82740400003)(70206006)(86362001)(5660300002)(36906005)(36756003)(47076004)(69590400007)(6486002)(81166007)(6512007)(956004)(2616005)(16526019)(8936002)(186003)(83380400001)(44832011)(2906002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 2f3e8ea5-b6a4-4c14-82d7-08d816b4c914 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0gQh3e6fOsurGf6fCb4/oFXBv9HnysU7N7azn7PlabT2R6SnOClENrKrf5I50b3CXEGL2V1Ux5UNIAa8TMDeeN19Lv859akJKTjNfnmnyciLO4DGmy+mDX8TYX7h91fsUbC4uK1knPQFENA3HrzyGJH9NLyOK4tXd2Phv3UziVkMlZL1V1P7ZqRlO558qDfYm3R8M+kIx3ec9a2MPIvJUmYnbPJails7Rb0MdNCwTiZkUB7lxZvoAKyx6X0Njz0PT4d25OhIjqbpLuaOcib86QoKcLjMm2373LCMLwY/skSuie/gd/YjW3+3N9tUgRn8SREdnR5dEtZ4iUGHNcSx60NpwqpPL96nYXyyWAK7eVFn2PXqroXZ/iK2b9KUYDFg0oKc6vm1VmTPTfmI4pXC6aRgoup8Z1l0CtJB0vr4tFVCRcLZfFASsC9ep+iq+NDCAbQ+vpavlkWmOai0uD/5/g== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:01:46.5547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 873594c2-b972-449d-9ed2-08d816b4cd3d 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1981 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This is a new security feature that relies on architecture extensions and needs glibc to be built with a gcc configured with branch protection. --- NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS b/NEWS index a660fc59a8..7d0ca3f520 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,18 @@ Major new features: pthread_attr_getsigmask_np have been added. They allow applications to specify the signal mask of a thread created with pthread_create. +* AArch64 now supports standard branch protection security hardening + in glibc when it is built with a GCC that is configured with + --enable-standard-branch-protection. This includes branch target + identification (BTI) and pointer authentication for return addresses + (PAC-RET). They require armv8.5-a and armv8.3-a architecture + extensions respectively for the protection to be effective, + otherwise the used instructions are nops. User code can use PAC-RET + without libc support, but BTI requires a libc that is built with BTI + support, otherwise runtime objects linked into user code will not be + BTI compatible. It is recommended to use GCC 10 or newer when + building glibc with branch protection. + Deprecated and removed features, and other changes affecting compatibility: * The deprecated header and the sysctl function have been