From patchwork Wed Jul 8 12:10:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39965 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 DB9B2386187B; Wed, 8 Jul 2020 12:10:47 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50085.outbound.protection.outlook.com [40.107.5.85]) by sourceware.org (Postfix) with ESMTPS id 33E163861834 for ; Wed, 8 Jul 2020 12:10:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 33E163861834 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=NynhcMH/U7xwYndGvy83dkNxlpa9GjZcpU3+DvfIAiw=; b=Vib7ocMlrMzRZD6tZDjnbppjpeQYJZjqsoTdkJOMBqsPvRH2guYdkd3lBEzQVz5IAOpnWERptPVq2TurIW7wLufpvMifs0U4Kq1g/WcCLOZIlMi7K3PC5PJi4rw1PCZUHitIpnYqEixz6aoILeElmW8E8BcnJfgAciAZFNswPPE= Received: from DB6PR0202CA0038.eurprd02.prod.outlook.com (2603:10a6:4:a5::24) by VI1PR08MB3086.eurprd08.prod.outlook.com (2603:10a6:803:46::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Wed, 8 Jul 2020 12:10:43 +0000 Received: from DB5EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a5:cafe::c1) by DB6PR0202CA0038.outlook.office365.com (2603:10a6:4:a5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Wed, 8 Jul 2020 12:10:43 +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 DB5EUR03FT034.mail.protection.outlook.com (10.152.20.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24 via Frontend Transport; Wed, 8 Jul 2020 12:10:43 +0000 Received: ("Tessian outbound 114f46c34313:v62"); Wed, 08 Jul 2020 12:10:43 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3e489e621fd06af1 X-CR-MTA-TID: 64aa7808 Received: from 65b03a43ba17.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6611F75E-F4CD-425A-9979-E75ABA9644D0.1; Wed, 08 Jul 2020 12:10:37 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 65b03a43ba17.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:10:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E6vW+ouHrvpGtMvcGQ3MjpoSFjiEsqDX3xBGTLhOitDcRE5/t5pLWCrYYCku+fDUM8qcGNRq+kw84oVZ2bC7KUBb7Evie/LBZVIlAufauB5iLrfhQzQAjwKI2+zwdhlsNozf3SuKsN63+OgBI/Ez3lqDTq34DMFA0Yjr/BwYK5ztFL/DOZVrGT0y7Co4Jh/YHet64Rp66s/K3ZieQ/CMh5nfdgvH/MuRcDYp+yt2syysyMw93FWyPwMFUsYxZ9bTzUcyjlEHVRGLl5OKcHxtad83I0qwLjxnN4QPdL0g0tDgUMwSv/s5S+SWNDPFppNbI4Fczzx6/UfIZ1WbPuU7qw== 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=NynhcMH/U7xwYndGvy83dkNxlpa9GjZcpU3+DvfIAiw=; b=c5eTdPdCWAqnk2ACT+pooLIgMUrAsqeh0NU/z5hJ0DOhiM6XtVF++lsblIkZpup2Y9/N+iZtcR3Ur+98iccCYHfWQCBxogPRDmja1x9HCUD+Ez0JZpB+JeEeMNelwDB6NFfyMcY9TYLoZIiTBWH/cVd7qjdX5KBxTuz5ppS4u8d6Pru9XMguJf2zdifnzSjvjElmADmVmxnVXWhNdqt2pboBHNFWZvuyYwQQVE1mgtA/6VR9qcn1WXUboFx+KWf/6EJ1qQ4ysTeRMm/KsKvCmZhmUwTDOGW/SmPwqeer9ZhS+ehl6p/II7foNwBon+pRBmWMAZYyCTJ0wkrgnaDOCA== 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=NynhcMH/U7xwYndGvy83dkNxlpa9GjZcpU3+DvfIAiw=; b=Vib7ocMlrMzRZD6tZDjnbppjpeQYJZjqsoTdkJOMBqsPvRH2guYdkd3lBEzQVz5IAOpnWERptPVq2TurIW7wLufpvMifs0U4Kq1g/WcCLOZIlMi7K3PC5PJi4rw1PCZUHitIpnYqEixz6aoILeElmW8E8BcnJfgAciAZFNswPPE= 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 AM6PR08MB5238.eurprd08.prod.outlook.com (2603:10a6:20b:e5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Wed, 8 Jul 2020 12:10:37 +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.3153.031; Wed, 8 Jul 2020 12:10:37 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 01/14] Rewrite abi-note.S in C. Date: Wed, 8 Jul 2020 13:10:26 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM5PR07CA0029.namprd07.prod.outlook.com (2603:10b6:3:16::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 DM5PR07CA0029.namprd07.prod.outlook.com (2603:10b6:3:16::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Wed, 8 Jul 2020 12:10:36 +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: 4ee7c93a-6c45-4696-3e5b-08d82337f015 X-MS-TrafficTypeDiagnostic: AM6PR08MB5238:|VI1PR08MB3086: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: P8aMPJ4d//YVz/5XGmEwi20Wscw7qDfxHU2jlduu3S5PT+bESp5g4ZgeZRxYfhr3nvYvojrw8tMp5B6KG+Gs9tHjsCpoP5iQ85AKde7oHNqipigJJ1CJKxyAXHnNz7tW69Pc3HXt9heZF+TfskBxZmtOPahRojCm4VJvbSPlm50Tg9HICXqHNtGyhuiQq8vCoO6BKkMGoPcE+ftMJM+wh5Fzhz78zNvi4uzqCULok4UNXI5LsLunypwyrNS2m1yWYeXXuMRTUiEXnCgzzy3hQJ26zC6X8Uc0b7xv7j1Ni4l/sehHLWC23PNPcdWeTNAGSZzgxIvRF4ehWJBIPcQYECkJBm9OftZ4KQzjYD3grquwPXStsl9IyqXGUWR3goA3nw2/g9hJqObjOgGhiY+ENT/JrMXqPh6OL/jvgi9O4lY= 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)(396003)(346002)(136003)(376002)(39860400002)(366004)(44832011)(6666004)(26005)(8936002)(6506007)(8676002)(83380400001)(956004)(478600001)(52116002)(2616005)(86362001)(6916009)(66556008)(66476007)(5660300002)(66946007)(316002)(36756003)(186003)(16526019)(6512007)(6486002)(2906002)(69590400007)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: BlqZ0YZShnc6Abtbrq3An3yGxuiy04zooLgQihNSZ34VP2ttgfnvMMUkr+a6ivTJPOSYCjrdhmU/AwWMh2B7bnv9lP1XDR87v3O+kxowCPuu36YdIfngPdUvj5FGzuWoo0+bNb68NrA3SqXulTtdpvP6/1yKnXEnfJXh5Wnz13THj1QW+hwZJJXZP5Bwmqs76yE4bQaaVOap0mWrxqboy0mBoyd/GKBACwXSI+K+yRvwkLyQv71r5lCjIUaL5OXpcnlWpUI1xSzEd2ey12om74zFilKWw8l4Cajljb7PhskyOBnRD7ce6ARtwEjBlEReAORBXZ33OsZpApsaA+C6h/a7wJMoKQUkFXbtpMMPiELg+USDCArYIAN1BmKrzRpKzMVzaXz8eeyp8l1gVdTnxF8uLrGmDU4Ya2q7C7fzhjViSJ5zvYaE6ktzjKm9n+TNK1u0Iv393HyPBqOoIcC5Mj0PfsH/jXtH6/Ju+l5lZ3k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5238 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: DB5EUR03FT034.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)(39860400002)(346002)(376002)(46966005)(47076004)(6506007)(44832011)(36756003)(5660300002)(8676002)(70206006)(82740400003)(70586007)(81166007)(86362001)(316002)(26005)(6512007)(82310400002)(2616005)(956004)(69590400007)(356005)(478600001)(6486002)(16526019)(8936002)(2906002)(6666004)(186003)(83380400001)(336012)(6916009)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 8f08af91-4beb-45fb-f769-08d82337ec3c X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zppqlJOB8BHBV5gIKZ29PUpscsGyywF1ur7IsLo+PuzJhwIcuD44FXTAnRcP375xGGKi9CY1MtS0ae6+OZd95eTg11s+wTeVeJzRG9wzL2YNJmr0EeXNjMz0riLsal79G/S+vuVAim/tXQ0jgj2ql4nAq0zqvkue9QkKEvYdsN5sYRKyMnlRMr4rdQ/MyRKLV3sLsEjCt5B4+fkGjGSv+j8BVuULJYb8TSuZ/JuyHhY4s1XlyJHhlWdW5GRBSqXyueP8R5zfm55ghNR+vZm5f07sBOozh/J1mP0XJGzliYKs5tKg2Y5tqy48q1xJNs5qywbHmSoIbY8ZkvKY3r6gNeB2jcL+BRgTyurM5kCM9kY2Y0Ke/k2amdHfjD4PnZGSjdRE2rbD4SQ20tdmbgxhO0v18w5Z+drmwlEio4IxDsZtphL5jHulIOTyxQWocK2BslTRIE/7vHN7/IoxhU/8CA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:10:43.0792 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ee7c93a-6c45-4696-3e5b-08d82337f015 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3086 X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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 protection. --- csu/{abi-note.S => abi-note.c} | 25 +++++++++++++++---------- sysdeps/arm/abi-note.S | 8 -------- 2 files changed, 15 insertions(+), 18 deletions(-) rename csu/{abi-note.S => abi-note.c} (89%) delete mode 100644 sysdeps/arm/abi-note.S diff --git a/csu/abi-note.S b/csu/abi-note.c similarity index 89% rename from csu/abi-note.S rename to csu/abi-note.c index 2b4b5f8824..8febf4cac0 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,16 @@ 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 = sizeof __abi_tag.name, + .n_descsz = sizeof __abi_tag.desc, + .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 Wed Jul 8 12:10:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39966 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 888CD38618BB; Wed, 8 Jul 2020 12:11:07 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70059.outbound.protection.outlook.com [40.107.7.59]) by sourceware.org (Postfix) with ESMTPS id 85D913861841 for ; Wed, 8 Jul 2020 12:11:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 85D913861841 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=QxeFC5qmo+ItRdSh9AYP94EE7hhDDTCdDJUgYrLNETU=; b=NeKu1Su6bk4yCc5/xcnEJ6EaKHozkpCsWuPMGBU/+OMg/CvI8IP2LFPfAnDdT+tuagLfP0qMpDawA3bXKP7iEM282/nyRA3VUe5G/gNeQhDK0hBG0627gGv4P+lcUaDbpZVzsMWYetALRUFA5YrhmnYtYGwAu3kkNeEmgbKlrvg= Received: from AM6PR04CA0031.eurprd04.prod.outlook.com (2603:10a6:20b:92::44) by AM6PR08MB3304.eurprd08.prod.outlook.com (2603:10a6:209:49::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Wed, 8 Jul 2020 12:11:02 +0000 Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:92:cafe::ed) by AM6PR04CA0031.outlook.office365.com (2603:10a6:20b:92::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:11:02 +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 VE1EUR03FT053.mail.protection.outlook.com (10.152.19.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:11:02 +0000 Received: ("Tessian outbound a4b10e5b482d:v62"); Wed, 08 Jul 2020 12:11:02 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0421ed4d0df2c2d0 X-CR-MTA-TID: 64aa7808 Received: from 6c2799e1bb09.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F0F84366-FAEE-4F70-8733-C762100AE6A9.1; Wed, 08 Jul 2020 12:10:56 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6c2799e1bb09.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:10:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=niiTGUlxRmYSiGaeIqW7AIJvW3T55Qa4VPJVePJGmXHO0SvrwZqtR7kYOdu++zseAEZpgQkHQfu84XGIgtQzar8pKCv3xeqzyCw1nONY4eBG7Y6s7OkGxYkhQZxP4ryxcX9CpM2gWkFmJ5GHJmkryNf9xPKeAWVZ+16QuGKGCaq577/QiwtMgCSJd+12Yv+r0s2d41Ua0w5uqtyUv2zkNFggETtBRosbFiAD2/N+1bWc6Ru+BJ/CCHwz4S7w+MCgtExqGejU9Kdzp9IY+8c0kYqXwPhKHur1aikdtwLBp85kYjvAxeNMIPfRUk6zdI3GJd6Fj6XALS1gwH+aVu74PA== 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=QxeFC5qmo+ItRdSh9AYP94EE7hhDDTCdDJUgYrLNETU=; b=eVkxgD/mpGFDTUlrya6bUI7mY5d9AiFe1rR38aMwPC5u5LbMZYauIadwX/asz3HMze5B2JcqlEsw39RqVuNGIun1RAQ35KDNB1eupmsm5QHBK65w2MIrUX1TD2988EJQt+6+Ctpn3yNYQxydwiL6YGeoPzgAumw11ZhESH14ve9/HeoVWG3tzOq45Y0Mg6wi2HK5PcpqARr3TC5h7ZeitbdGVrBpnnuZsU/lnQQhQmAndW/+/fsZqhoZnytVIQ6L6avHY3Vb2NRWPlxfn+mQZ6oR5VStj706d4du8OxlsucNLGJBA7B0PJJmp0FI86XPNbcBGx3BKPMC5kkIMQdxuA== 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=QxeFC5qmo+ItRdSh9AYP94EE7hhDDTCdDJUgYrLNETU=; b=NeKu1Su6bk4yCc5/xcnEJ6EaKHozkpCsWuPMGBU/+OMg/CvI8IP2LFPfAnDdT+tuagLfP0qMpDawA3bXKP7iEM282/nyRA3VUe5G/gNeQhDK0hBG0627gGv4P+lcUaDbpZVzsMWYetALRUFA5YrhmnYtYGwAu3kkNeEmgbKlrvg= 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 AM6PR08MB5238.eurprd08.prod.outlook.com (2603:10a6:20b:e5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Wed, 8 Jul 2020 12:10:55 +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.3153.031; Wed, 8 Jul 2020 12:10:55 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 02/14] aarch64: configure test for BTI support Date: Wed, 8 Jul 2020 13:10:49 +0100 Message-Id: <213866f01f7ea12adf76dcce1d1404d8afa7a7e2.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0441.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::21) 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 LO2P265CA0441.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Wed, 8 Jul 2020 12:10:54 +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: d93fac84-1294-45a8-3e88-08d82337fb95 X-MS-TrafficTypeDiagnostic: AM6PR08MB5238:|AM6PR08MB3304: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 67upPpBi9RFcCLS8cd6H70YqwdIREpbrszj8qHJwETkuUlV4QYJYdUw0fLHLMSXDveBvsqYssE15GbGT3S2AsepVEQo1sk5+KWgOWqz0jdGoek9sny4joJxQUpqnHfTzGiN+UdA/AP+nHYybESfjpCgJ9G19ieFCO7OBtySGSnRPqERTFG4285Xogiee0wUANbHNqjOdTFu1TCgtk2G+C+NlvsZglGm+Cbvv2VzjfVjSDcKYyZHcs0QHuy863i3JD3ZbgOOV8hdo5b9qupFTFxiqOTwdVdjz3XBT7d+0aWHFh8PJgwDf6zNkazXbAi+UOaJPX9ak3e/46cX3PdEvNY3/TBEX2mrgqYvjLXRHEsEbWu8ZL+HlwkK0U3v7VkudVrY2mXJZdDQSWiUoosgVWxqAj7Q1ax94D4eyLzdmuuU= 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)(396003)(346002)(136003)(376002)(39860400002)(366004)(44832011)(6666004)(26005)(8936002)(6506007)(8676002)(956004)(478600001)(52116002)(2616005)(86362001)(6916009)(66556008)(66476007)(5660300002)(66946007)(316002)(36756003)(186003)(16526019)(6512007)(6486002)(2906002)(69590400007)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: IaH4GX0U6hVLMUKM5Obep/WPRVJSq4yQDx2LDyYhMz36JdG9VsupPNi/VZgPF/3H2rY34GFGYAkqkekurfhTe+Q2lB8SfQDpS4VSz1yOQ3zQAB2pGe/dl0KWsvjDTrHA2Nn5ZUYtB6K62gF6p2rkbtHxOeNHNXdsblgVGcbqLhRmxqAwyISDhGwsYDwIwZOUatHwXTzUqdBIrAxFbsliuc02t3uhN9xsRUgYgc2Lece941KHBpLm5xUP0YLaKQWiNBd9I4EpPFjXUagv3HpWuzzbTBZU/TXrdOai7/2lGkysMfRgTuDuySoK7IGlsREFtwuTdnuOEP52tdcTkybNyx9/KdWVHrOfy276lkOmlc/bPLQrFQ0PGyd9AH5m3i4hZD+eGCQBTkd3lITVylt5lU+0hIuhsWx5LOCw+9ydIBdAIxIl4F2xLSu0VNAJyZjSVDGhadIK0LLErc3MTgHumdov4OxX5CsuvFccM8mJFUI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5238 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: VE1EUR03FT053.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)(39860400002)(376002)(136003)(396003)(46966005)(2616005)(6916009)(356005)(81166007)(16526019)(186003)(86362001)(6506007)(5660300002)(2906002)(70586007)(36756003)(6486002)(6512007)(70206006)(82310400002)(478600001)(6666004)(47076004)(26005)(956004)(36906005)(336012)(82740400003)(8676002)(44832011)(69590400007)(8936002)(316002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 0cc7f3e8-1c47-4d62-aeb5-08d82337f725 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3d3fK0LqWeyWAYi/yFrAytjy5an5mESs7Pd1ekDbtX6bMpdpSLd7hnQsZLiYS4pbCbmV7h+zXx3IdFYlqldTc+nfa+lbQ2dvBFn5rPt0wpZMtkgsP6tmUXPEB9MKPHXfqEWQwSUWk5W0/WfBDQIn0ij+uJtDu6GhAfBSK+beNaKdd5RMTUOJMBelBuj5IAn9ip1XdtVZwzXHY4eWLzCivtCohrSJLF7iC2Xkry4OD72s4IYJbLQjl+eGLvJuhdjQgJWy72qch8IkypLa1NCo92cmuAWPk/wNzujcrzJecEpV7AQLQmUDH6b2b9B+0ZlmSVLWhDSdJmJWGc1IFQZOo+tG4LO3b38vJ+oiieWurbcU4FAbPOee/bdGEwVujk5BBHML6FOjtclVviGb9RXz1iOAIjTVzbJ6Ts6UMUU8tfTLsVlXQ9K5YKza6USbkLChvn4R99dEzDrwpMQfUghBZQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:11:02.2861 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d93fac84-1294-45a8-3e88-08d82337fb95 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3304 X-Spam-Status: No, score=-16.0 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. Reviewed-by: Adhemerval Zanella --- 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: 39967 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 ED35538618CC; Wed, 8 Jul 2020 12:11:24 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20051.outbound.protection.outlook.com [40.107.2.51]) by sourceware.org (Postfix) with ESMTPS id ECA0E386184F for ; Wed, 8 Jul 2020 12:11:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ECA0E386184F 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=gMo2T5g/U9bNxzf7yPajcM0Wktd3GB0PEuHaD2ns1Z11ZDioYzBq0fbGrZ3tn2mQrYqmpnsenhr7ZeA0OPRjkSoVHOIcbRMhAYb8PitiInKvoZZZZuourrCP6d3njctLtl2fWt+/IPbNDZ1lq5z2GVsmaZgBkrnRBx4+9ToMJ1Q= Received: from AM5PR0601CA0029.eurprd06.prod.outlook.com (2603:10a6:203:68::15) by VE1PR08MB4975.eurprd08.prod.outlook.com (2603:10a6:803:10d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Wed, 8 Jul 2020 12:11:20 +0000 Received: from AM5EUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:68:cafe::c7) by AM5PR0601CA0029.outlook.office365.com (2603:10a6:203:68::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:11:20 +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 AM5EUR03FT013.mail.protection.outlook.com (10.152.16.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:11:20 +0000 Received: ("Tessian outbound 2dd9eeca983c:v62"); Wed, 08 Jul 2020 12:11:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f765e2859e973ffb X-CR-MTA-TID: 64aa7808 Received: from c74b266876a4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 16399FF9-9E78-46A4-AB32-33EDEEABD327.1; Wed, 08 Jul 2020 12:11:15 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c74b266876a4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:11:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JeujoN0eWmn2TzU6BRfVYnjATUrd12MJhietSDlH+C42rehPTJTGA0iojDSgZ+5KU3igCB0X3uNQFzaMIOmtwA7xbg2VNeWJff6vQ5LNH8tZPUcGD0bet73M2zjrSxE3SuZDmn6nbxEK4Z2yAvb/C0Qc1V+9FE/huczJyQ2RFJFWuvYAvaX8E8lXIapTD8a4TlJMoaz5Kabs0VQfd0ViOyOM2hpoF2KGhlD6bdkDNhKLcDJnVuN8ykbsSwMS7avnXxoKy13KTyt1QSVuQi4bj5uXnyIW8hY9xdkto8hT2BCBMOGzOqGceMI+zQ5BPlxoTaB24UiXaTLddqeyLRshCg== 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=TOiPfq34Tjl74ZYfPN7LkQb7M3Uc082a7+xxTR6kXdVXXmC0ZRK8SfvfdAYVR2vK+L7m6r7uMCCL+9YMa6nMVnjKBFTVd9Vu96ORm/Rz4JPsNa1YQ9G6MZYOh8wsbbXwXuyFMadPCCaFsfhJ2j5wig6S1x2Tenm+RCkezUDKs67dBSsIijyaN9X8cvlGerC2qTV49lpFzvmEmhmeSARJvq8YjcrVnix4Zh0w5bk1cOOtw6lsh2qJ//pz5CUhCq0lzR7bYjiT3C3n0yxvMbtVsfqDZgQgsJflUbG4d3qngxiP2s/AhzhG+YrmdCtqb6jk3x49UVWdJU0TOZuk4QaSdw== 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=gMo2T5g/U9bNxzf7yPajcM0Wktd3GB0PEuHaD2ns1Z11ZDioYzBq0fbGrZ3tn2mQrYqmpnsenhr7ZeA0OPRjkSoVHOIcbRMhAYb8PitiInKvoZZZZuourrCP6d3njctLtl2fWt+/IPbNDZ1lq5z2GVsmaZgBkrnRBx4+9ToMJ1Q= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:11:13 +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.3153.031; Wed, 8 Jul 2020 12:11:13 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 03/14] aarch64: Rename place holder .S files to .c Date: Wed, 8 Jul 2020 13:11:07 +0100 Message-Id: <7888f2b650699af79188e9d1a3c281a7a3429b95.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0202.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9e::22) 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 LO2P265CA0202.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:11:13 +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: b7cf698e-6b0e-4eb3-d39b-08d823380666 X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|VE1PR08MB4975: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: y7/fySfAx9GjbfWz8P1vuxXCa9VuQw7nF5MfigpwfXPJpnj4+Of/o33E/VQwoGBpy51fF4L7NQAL0Y+7pApHfWfsN/tV7ce9AwMwXlVvUqObos0vJ7t2sV+9I1VLymgFw42ONv8aEUaYMcm/TbQb+1kUP3X5JFCwt8KsQx7JEIkBEarf/7w/ZiurhkFkxBuYT/X3sgCHG9ICZdXhAFYDzCDqq7aRs4zNcBitToKR81K/c1H2LGdnBbpT21a7r/d2toaLmpKENuTEBSLEN8IyYo8UhUymLL3kr+CE9hpr87xU2BxSLxvHuH044IkyRruNHbFwVcC5edfc38GuU05oe+uHeK2h11St5aKNySjQ5JUeSgCmASui0uGAbaZpHttpoBwKyYrDQt7HoW+qlyoSBPbNey2qwF6sN+RbtKaneuGnz9/giItWUMAcnLp0ws/1 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)(366004)(8676002)(498600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(142923001)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: yT1D8+TTK6dB0CPyaisc2Vy5F0hy5E6OE9IqEA3o+yH9zS7MKyWDM0k3rnJLY7Zdwvdvn84f2DOib7UrlvKYWqJvy/y6vVlFPRfQ39vLSRVAKayC7apMhP9boSDGN3Gg0b+RsJElNqRO2YgWYYotEi0aXTywexCD/FZncUglmkv7y3gnvzutQO3d5R7XR+9dEXPFV8fpk4rROEOKm230Z5ex7VQo1p4l3+OYYxsm+nw62MTBA6mpiYfRIikKmTfodutaleeM0cpUiRwLxDLTyAlmkTNX5rIaRhpEqdwigth4vFOtJ/+ZyZMNohFDrzhE5q64WlUVpv16GjINkvPaVOUB+wcfGhshLVLqEmuthjDFLaeBOHAVmz+h32blxfzRjyWjsTEc6auCI87l5d1bl731DS9E4NJiMFKDrEbTixRSKEI+cQyIeXCKFiDvyCtfP/bCOFsxUOI2Nl2NPvnp9S7iOu9iLXnSY3J3uuXJnVE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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: AM5EUR03FT013.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)(136003)(376002)(396003)(346002)(46966005)(36906005)(8676002)(70206006)(70586007)(6916009)(83380400001)(2616005)(956004)(336012)(44832011)(86362001)(478600001)(6666004)(69590400007)(316002)(6512007)(8936002)(36756003)(5660300002)(16526019)(2906002)(47076004)(81166007)(82740400003)(6506007)(26005)(6486002)(82310400002)(186003)(356005)(142923001)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 2a0af0fa-62e4-42e1-d5fa-08d823380219 X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G1R8Dwd6uEu42FvhxDPPSvVBKPaFED5SBwYqccKW4eUg7i/RZS/x5SCkI5Nav4Vc2tKOIOJWzYcULdWExc0tmHgv7Oxd29jm7UZKJ9vM4EmPtIWxgZ32p16bdUvvCuf4xd7xo5mWH5GnwP6rphHxULx3DZLmD0bxF0oMWoAI9cV9R+rLG7IpQaf4VnuDTpSdJCwDAHlzOJO8RVAs5WXCowmm5yBHbGPpFm4Fk7C5DwH/cBNPNB/hZPM0rwCqTMMn940/GsiR3F5I4FBpqkGbcdlJPIZpfOS6NJCoN7o4NE3qK6DgDKqw81w9SW+AKhsNP2XXp1pQb6HsL2+o712ZDsTiT0mALP4YB0SrtBhQ0uZlzDq+/SKqPPbP1dd44ksVB5bPq6ll2m1o3069fLlKGPRtVUSMVcsw473r22/C6aeIr2PKl05m2hzJJSIQaPqxpQUFciuV9w7OtPqAhxdo7/jyl+ZIbGb625AUzN8cGSroqCMJoMVONWwhMD+b6ux3 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:11:20.4858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7cf698e-6b0e-4eb3-d39b-08d823380666 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4975 X-Spam-Status: No, score=-16.0 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 Wed Jul 8 12:11:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39968 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 C2C51386181F; Wed, 8 Jul 2020 12:11:44 +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-eopbgr80074.outbound.protection.outlook.com [40.107.8.74]) by sourceware.org (Postfix) with ESMTPS id 6354D386102B for ; Wed, 8 Jul 2020 12:11:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6354D386102B 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=BH6IkRfSfxpkwTJiPkW7uggKGGNUxljZiAkozY9l/hY=; b=SCwzVw2fc0fpiDCwcDC2svG02tqE34wd/tnRGGt2EsNQVqA/hhcZ2MqpWlq21IDG4CfNrmyz9rYrkOCdrwqaaQ5jNSvu+W9reUVdba+ELbMPp3vtFieW4PJLuPRaURQCP9Te3lgRG5IvBP0UKtUElH2agDCUo9z8Xwn5v/7sVlE= Received: from AM6P195CA0058.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::35) by HE1PR0801MB1818.eurprd08.prod.outlook.com (2603:10a6:3:7b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:11:38 +0000 Received: from AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:87:cafe::61) by AM6P195CA0058.outlook.office365.com (2603:10a6:209:87::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:11:38 +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.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:11:38 +0000 Received: ("Tessian outbound e44de778b77e:v62"); Wed, 08 Jul 2020 12:11:37 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7105d0f7223b36c5 X-CR-MTA-TID: 64aa7808 Received: from 8db0bf1b6f2f.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9261EB7A-E2D4-4084-97A6-B010AB44590A.1; Wed, 08 Jul 2020 12:11:32 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8db0bf1b6f2f.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:11:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gk6iqZ3LqxB2Y4yH0WCvv7hRn+R6YElR4waJCe1HCdc9eywrpv2nruUBcVe3LiFgnOORMWgGxv5YT2GXnQXahz8DVBz5WiZFL6A9K/IvjbGYF56awdudvC42mxrV5nPC33GzI3OcPQctne4YP9OAQsP9lI4ykVoVeukefzXTzx+6wKseWq9dTThVJUUcVB9y7oC/OAadMSZPr27nFqXN75ShEfaXiI4/0dXaaE9ac6VJDTIfJBnaYtp7pADZCb14g1JxnRPbTSb/c4/qGXgYzjXR9d3H7DZkGENW6Kj/KxBc5sxi9WGHLvWtRuuuRU/7l5Fau85v575aECjwnVz+IQ== 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=BH6IkRfSfxpkwTJiPkW7uggKGGNUxljZiAkozY9l/hY=; b=l61rgcMp0mXfkhfVDyc/1FMFa8ne/Rn5xEsbQ0AlhM9/ZvLiYFkX+WDWAUe0tL7jzNEm/UvR1iPb2Gv6pEfyGMqzEUdIW+6mx65v2rG6kfmr9KYa1WyxcIbk++j0TUgjg5zurn2FAJKXSCpd4wZ0P72NOexq4nDWY9ShKhLoHZN1g8lCChre51N4vlKh0LrWLxeaHTSvzItVx99Z184nyfLR0BM5em+d349KUf+/Gb7J+GFpyQe2+II/fkYR6QhEjg4vonxeq9JSoP7ZIxZa1UT1IiaGC+Xht/Vud0sBHmTcUVGpco4tnXIVh9KFZlj6ebg+LJIEP7nJRK3+MX5+Ig== 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=BH6IkRfSfxpkwTJiPkW7uggKGGNUxljZiAkozY9l/hY=; b=SCwzVw2fc0fpiDCwcDC2svG02tqE34wd/tnRGGt2EsNQVqA/hhcZ2MqpWlq21IDG4CfNrmyz9rYrkOCdrwqaaQ5jNSvu+W9reUVdba+ELbMPp3vtFieW4PJLuPRaURQCP9Te3lgRG5IvBP0UKtUElH2agDCUo9z8Xwn5v/7sVlE= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:11: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.3153.031; Wed, 8 Jul 2020 12:11:31 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 04/14] aarch64: Add BTI support to assembly files Date: Wed, 8 Jul 2020 13:11:25 +0100 Message-Id: <706b5cf41102a7b52d8b3e0f6b84704441127524.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LNXP265CA0070.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::34) 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 LNXP265CA0070.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21 via Frontend Transport; Wed, 8 Jul 2020 12:11:31 +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: af5c75fa-debb-4fa8-f396-08d8233810d7 X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|HE1PR0801MB1818: 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: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: FWEEjPpdUMJZyVBx+t1Rkp5OCEaaL/Yv1ojUsuJHD/nWrp6kb/8bV+qXPnSoVKk3L4awahzug2OHlTjn95JaKk5yr14sESeGx7SLxePEJ9wI+msyzYiT4R+1Y6Hb6tFvOeT/sxs4y3M8g0OMj+tPVUEltGg/daTx6SBeSJM7MhObjXcu9kVQCRmRQBXdHeakGu0trqHgQYqX8GGeDgBmrnAc+K4vXlihAJ44kthJYI1Fw2abgvMfdZZ2JfWANW00QdPW/ai2J2DcG1szGC9+pgbSICm4jZf7F6PLMwkgdpwSm1gJbBKhPBbineS44iiwJ+QGclNfzVvVPF/thGZaeLiqYYXUyk5Tdsh1XJzZ0BlPN8ylOG7Plnt4Y4zo3rmXKfDNJ+gkNI/9U+mD5PZVR0loPk+6Lq2QMAYajOOBXlCeskPd3dcqqq2TqEUg0Zjd1vnLq15WbENOvtTRRvcF/zAiwypSM7Lpm3iA0ailo31TOPmDAw9ucYNgKKq6LPkf 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(4326008)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: IuclhJOKdhMvyiTAP/e+5zIERNXruwZUVarR24rB31nsY6BvR9sbv3sA8HOZYU2fLON2eCt86rkLxqQL26sSFpbf/Bxof2Sr/zfcHjVJiVw6EaQaPgZlyNScTGl2a+n5c3cI5CrOpp+vIDKmfxTfDiIz5RQgIOS+A3Ee/nc/LGruNqWE2UrHDpL1MRslJEa9+HvjzKO+5soI6wV5n9Mde1npIzURnIQBfPn+S+UI1ZJkDkflzFM3CGtYNI+4BwRBwlu4/7Zd3RWgKNIpH2DawurKYpYemQu0mt0OlvdshRJNgiUQJDOl3kD5jUvUj5ehWDyjILChTcDOp89gD8+ISFQyMSecXGRJdOKmYFvDyV5m2EK3u00Wvt8ee6ss4mC0ybcN2Ra6fC7RaELLW7CVKd0InmsQVU8WpVosh18bAJ7QSww8ylxJEYZkSRFbcthrlGJasHh6yvSsvdSjsrzcrGcVa00rU25wGU8Egu30uoU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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)(396003)(136003)(346002)(39860400002)(46966005)(82740400003)(4326008)(69590400007)(47076004)(6666004)(5660300002)(81166007)(82310400002)(356005)(83380400001)(86362001)(6486002)(6512007)(26005)(186003)(16526019)(2906002)(956004)(8936002)(8676002)(2616005)(478600001)(44832011)(6506007)(316002)(70206006)(6916009)(36906005)(336012)(36756003)(70586007)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 0f477f93-154f-4422-9765-08d823380cb8 X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tbBUPpJOeLq8ca0gmUhJ84QOtoYvNfviwPg2CYdVlzRYsXPSsgr8NvDQWc0VKTauvb7iHiYm8rqzKpcvEcQrOCZkrwIJBYq3SbikKiaUMKyvIS4UYC+IpDqxYpA2asRV7z/+FQmz41UMNrJXijfpaS5PA10mPDgQiWY4NfstEbVxEwSjlsvutAndCkaRy/bWcugA7lMponuzJJu9D/nUpK7jRDLCSaokTNMrI2+yKLKqL7oIP5fetsjKNVRGGHM9nmk9PHg22Rs7Wom3+oHhUnA2vSoaiFIOjDFlqZIqCp03aQBa/YgQXPXdiSNz++rPQ87oAJu5aCGcTn61lO2eYNlz8+xqkbL5mZ6Ja3iUQ6nOc/+RToKoWkjkEP6lEl2+5KMyft/Fil1ILmA8++0qBWNnSMpqz5yPTu26elq5SrS3RTVd56AMnMtam6RBqdM0zUrz40fMLBZRHWcOn3c7EbN5Yi92bjqxhFBRFwGJv4kBTv9lyGl2e5jwvpDzbqOQxI/6Y3lGshTLfk5zX/485/bk5dvLPiVbiuK5TzTpPPc= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:11:38.0094 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af5c75fa-debb-4fa8-f396-08d8233810d7 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1818 X-Spam-Status: No, score=-15.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, 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/multiarch/memset_emag.S | 2 ++ sysdeps/aarch64/multiarch/memset_falkor.S | 1 + sysdeps/aarch64/multiarch/memset_generic.S | 2 ++ sysdeps/aarch64/multiarch/rtld-memset.S | 2 ++ sysdeps/aarch64/start.S | 1 + sysdeps/aarch64/sysdep.h | 34 +++++++++++++++++++++- 10 files changed, 50 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/multiarch/memset_emag.S b/sysdeps/aarch64/multiarch/memset_emag.S index c4d3533c14..3c2e9d2903 100644 --- a/sysdeps/aarch64/multiarch/memset_emag.S +++ b/sysdeps/aarch64/multiarch/memset_emag.S @@ -17,6 +17,8 @@ License along with the GNU C Library. If not, see . */ +#include + #if IS_IN (libc) # define MEMSET __memset_emag diff --git a/sysdeps/aarch64/multiarch/memset_falkor.S b/sysdeps/aarch64/multiarch/memset_falkor.S index 54fd5abffb..154527398f 100644 --- a/sysdeps/aarch64/multiarch/memset_falkor.S +++ b/sysdeps/aarch64/multiarch/memset_falkor.S @@ -17,6 +17,7 @@ License along with the GNU C Library. If not, see . */ +#include #include /* Reading dczid_el0 is expensive on falkor so move it into the ifunc diff --git a/sysdeps/aarch64/multiarch/memset_generic.S b/sysdeps/aarch64/multiarch/memset_generic.S index 46c5329cdf..d746d1d00c 100644 --- a/sysdeps/aarch64/multiarch/memset_generic.S +++ b/sysdeps/aarch64/multiarch/memset_generic.S @@ -17,6 +17,8 @@ License along with the GNU C Library. If not, see . */ +#include + #if IS_IN (libc) # define MEMSET __memset_generic /* Add a hidden definition for use within libc.so. */ diff --git a/sysdeps/aarch64/multiarch/rtld-memset.S b/sysdeps/aarch64/multiarch/rtld-memset.S index 44bc479411..f9845bdd62 100644 --- a/sysdeps/aarch64/multiarch/rtld-memset.S +++ b/sysdeps/aarch64/multiarch/rtld-memset.S @@ -17,6 +17,8 @@ License along with the GNU C Library. If not, see . */ +#include + #if IS_IN (rtld) # define MEMSET memset # include 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..0eeb0bb2f1 100644 --- a/sysdeps/aarch64/sysdep.h +++ b/sysdeps/aarch64/sysdep.h @@ -41,6 +41,35 @@ #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); \ @@ -48,6 +77,7 @@ .align 4; \ C_LABEL(name) \ cfi_startproc; \ + BTI_C; \ CALL_MCOUNT /* Define an entry point visible from C. */ @@ -57,6 +87,7 @@ .p2align align; \ C_LABEL(name) \ cfi_startproc; \ + BTI_C; \ CALL_MCOUNT /* Define an entry point visible from C with a specified alignment and @@ -68,11 +99,12 @@ .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) \ cfi_startproc; \ + BTI_C; \ CALL_MCOUNT #undef END From patchwork Wed Jul 8 12:11: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: 39969 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 2F020386184F; Wed, 8 Jul 2020 12:12:06 +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-eopbgr80042.outbound.protection.outlook.com [40.107.8.42]) by sourceware.org (Postfix) with ESMTPS id 13993386102B for ; Wed, 8 Jul 2020 12:12:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 13993386102B 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=QKinLRJoigRkXkSfBZ/84WSaoMC/KWzXWSWAh4KKbYPw7ljITPqTfVRX6UmwbFupybHoazO19sdphiZnaNkwG6L1j3Rh1KpWgVuJnNtJCWv1Iz/nbRVUHdCgpMKggok//aiagLg3wiXsBhH7IhbRKLiXjJdAPg1yfStJ0avT0pU= Received: from AM6PR0202CA0053.eurprd02.prod.outlook.com (2603:10a6:20b:3a::30) by DB7PR08MB3804.eurprd08.prod.outlook.com (2603:10a6:10:7b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:12:01 +0000 Received: from AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:3a:cafe::89) by AM6PR0202CA0053.outlook.office365.com (2603:10a6:20b:3a::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:12:01 +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 AM5EUR03FT042.mail.protection.outlook.com (10.152.17.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24 via Frontend Transport; Wed, 8 Jul 2020 12:12:01 +0000 Received: ("Tessian outbound 4e683f4039d5:v62"); Wed, 08 Jul 2020 12:12:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1b57ae6a333a6097 X-CR-MTA-TID: 64aa7808 Received: from f696ed657058.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 82236FB8-CB18-479B-BCE2-ACD28E0DFB2A.1; Wed, 08 Jul 2020 12:11:55 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f696ed657058.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:11:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QBokewMzYCdaGpQnIpkO47jmahvztQQqwGy88VkehueuB4dfZbl5MgU1eo1xxJkvKjojnWwXcW/2ExzjenKBpFEWcYahpo0vOYV9vqFw5kqeqUCnzlotZGUNwGRq80jOTE4/zyrbPLMFUOm6Cz5jwhBnaN3a+/jbfriVU4k9TfKMUjLjLuaFhfZcRz29Rdz70kejPU79Y4u/GQxMGACgBOR2whuJEu7TFXdBKdvJS1zVkO8xLoACkWS/TWty8HEJxpWpiVuokQMABoPCvWLsLTJdEPHzuj4GVe1Tl4Apz5oZyAn7+iUklC+4LBwKM98nYw75PTTalySeXMn3LbnysA== 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=hoTcekRgyfq4wbbkJ8J3SPRo9LEwzuxVAYZ4LIuSI5i3TGTKIvwibUiIxU2UrdEMxcjBYNxo761qxkceE6A1bDOmqiJT6sW6/J8LaD6JXblTvLUHEEJ4vvC/ra03RxzAhZBbFejnbgIP0Zuo10FtnUWxLNGOW0ss2I4rjpjmgrcj/7ignQILG811uyiMfq7lwRJdTZRRB1ozm4zhaz8U2jprsr/7uR+8b5DqyLQHqFehFneBQhVAF/9wk97bAeqwS0CS4p0RGsloos3ivx/nqtUwcnms6BR96iPnbgnRkG/HX7dDyw39o7ulsLP46z4fc4RUhYjbsPa151s/QxuaJg== 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=QKinLRJoigRkXkSfBZ/84WSaoMC/KWzXWSWAh4KKbYPw7ljITPqTfVRX6UmwbFupybHoazO19sdphiZnaNkwG6L1j3Rh1KpWgVuJnNtJCWv1Iz/nbRVUHdCgpMKggok//aiagLg3wiXsBhH7IhbRKLiXjJdAPg1yfStJ0avT0pU= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:11: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.3153.031; Wed, 8 Jul 2020 12:11:54 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 05/14] aarch64: fix swapcontext for BTI Date: Wed, 8 Jul 2020 13:11:43 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN4PR0201CA0025.namprd02.prod.outlook.com (2603:10b6:803:2e::11) 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 SN4PR0201CA0025.namprd02.prod.outlook.com (2603:10b6:803:2e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:11: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: 97319aff-1c77-462f-15ab-08d823381e9d X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|DB7PR08MB3804: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: aQqaZgky8RNVh1rrYTozNGw1nJxKAPlvTlTBYtcYehk6RTKA1UBhnAc07RWsl3ar4M0gnuJ25pYDV/acrPUbftUsVieLjFHNp7TDQOdu9lk2P4aHbp4JnMFoBvTa2hpEG3i7OLW0YAznQcpRID8KKFtoZgH++ODOZpoVJJJIjgN/WMQYr8WUt4R0bBKS7itNhGymDJlq1Wzr5BmJ7p1FNSmQfqFvVHdyxnxvOx/enozuY/zkK/jXzJ22LNKyiMI6myYg16AEfqS04EtI6tao2Q6tLXF0B1rmijyHoOIwrf4Y6Uk87HmvWZBaxMnA4WGx9YFMteKysVLOoiuUxbqOq20OqoXU+3VqqY4QMCe7ClM8Qn1+vWEQkccyq6tGiyM80rnmenaGf47GEtjPxqeFtQp+vGpb7gurLTKbppjlpIk= 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 8TMgC83nkgYrBA5q0blzTxL6EA2PqEOY2dqnOhPgchXYONDdJ/4O/TRhGPhvvW6U3KUvAsfbK5SuUv7rIAshcnL3Xqjkjl43i66CXMaOurWrPMtbjKm11bHsM7ibhieDT2y9JYML9uiBpzx9K/7K8GZOYdG7VlJK8Q3z07jjuAMCVMfykgav/5j4Q/0sOo/Uu84/tK2rolEEGqn3uMEYwDD+fTKotmmZPKo7p0oYFh1ddcll1jRYjF9Nd6cI8wurEd2YFHFbpb/RTthV03+KzUJ18eZ5f8YDHMlloJzn7S86NVOQ+pYXAmjYaWLPTvQjJ2PNLyj6DCdo6nA/UXHVjDMiuRex/P0FEIz0aaNyKEaRWJr6yDLMn8+00JJ36XjPtJeHlsR+/iweT4R9iL+QotUVVw0HsAbRqSxsNRzda2G3tOdGySeYM5AfRQOK4cYxJDOr2LHDjclhr4JSNPHd0LYumJm7GfNTOvUqmvP8EBs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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: AM5EUR03FT042.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)(136003)(376002)(39860400002)(396003)(46966005)(336012)(6506007)(478600001)(2906002)(5660300002)(83380400001)(8676002)(44832011)(86362001)(36906005)(316002)(8936002)(36756003)(70206006)(82740400003)(70586007)(6666004)(6512007)(6486002)(186003)(81166007)(16526019)(69590400007)(2616005)(356005)(6916009)(26005)(956004)(47076004)(82310400002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: c69a8ad2-0156-4b8d-def8-08d823381a7d X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qm39MJWPiYkDXfZ6JySntYKyayV/Ru2R+WWasGHNTElrhIIPOpIX0QYp/DJ/n3Ynyvd0QCqfSL38VkwAgXzplBJvzm9ADxu5iIB6NPbdSD7zoS8vws5e1GSI7f+W1st1+eq6NnVO5Vf8KUFeqo4d+W2RrfTkFi/K4S+cHOD46bS2glORMxRg75lIX1NFZ4Dp0ZYCGbaThqYYApGPNCPMzhOf2ZT/qEuFYF/YlDRibPzXtY/gvI8ZQxQ3c9UV6uQbab4aoPP/7A/kgkiAtV92GqT3J8tWS2VnIZ/DKMMMXGxjTPlDYVIKi8Z4Vr4i9bncLgRhRxys0oXVplnDDzbxgfCQoyWTN0NWSW6jxrpEmldjxkf9Bee9fVqJteUd2tbnDt0DQYKtLHcNeFSa6fV43kweD1FtRLduvd6uChHiiFNJrV29VFilmkvq0drJ/1q+M+0yxEVEudpIXbEz29/Qnw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:12:01.1107 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97319aff-1c77-462f-15ab-08d823381e9d X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3804 X-Spam-Status: No, score=-15.3 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 Wed Jul 8 12:12: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: 39970 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 0D154386180A; Wed, 8 Jul 2020 12:12:25 +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-eopbgr00066.outbound.protection.outlook.com [40.107.0.66]) by sourceware.org (Postfix) with ESMTPS id D1894386102B for ; Wed, 8 Jul 2020 12:12:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D1894386102B 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=I1N9P48omYav++AgF54eQfEc8J/DsRz/ys2wfPAr3STPJPHdq2JuL9lTd+O6PP7DsKSmTuV6UX+Fq4ik0g/+7XsNRWnw6h6oIZif8FRynUFiHC2xh17MvtEvqSn3G9BIssyxkLrBluuxAdyQeKhkOdcmCAW9g5fpT6iFqe581oM= Received: from DB8PR04CA0012.eurprd04.prod.outlook.com (2603:10a6:10:110::22) by AM6PR08MB5173.eurprd08.prod.outlook.com (2603:10a6:20b:e5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20; Wed, 8 Jul 2020 12:12:19 +0000 Received: from DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:110:cafe::d) by DB8PR04CA0012.outlook.office365.com (2603:10a6:10:110::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:12:19 +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 DB5EUR03FT049.mail.protection.outlook.com (10.152.20.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24 via Frontend Transport; Wed, 8 Jul 2020 12:12:19 +0000 Received: ("Tessian outbound e44de778b77e:v62"); Wed, 08 Jul 2020 12:12:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 26163d7ee6c4900b X-CR-MTA-TID: 64aa7808 Received: from c515b2f61a09.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F69C0DF9-E78F-4FBD-987B-46F5B6A74EC3.1; Wed, 08 Jul 2020 12:12:14 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c515b2f61a09.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:12:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WJgvY5UwBd+0peNcN5Q6PryPqGltRdnOnIkZoeAekLkUKZKnznEAOsCMW3U5JLHVwrijl2SqHs2MyT/ZVZghfZBW9fHB7YGAK+5fGtKu/r2zEaslAmMPCUfwEAe5/T/qvc2BwYoOZa+7aHGWk4Tzfsac+clbBtwr4dlsgExmlCga2fB/p9ULTQNRVDRJXYnKIgB99EQ5LAxoFr8SmgEZ9PiXmrdZVGtuEMxHxQKUfY3KLFQlVLk8ryeCo26Y86jKGStJBa3lrjkxMTX8N5SeXrpitYs/G4oNOHjus2mhC+jBYfkXmm+ZMXJYb3gClmXZCsTLSoZ+azkPLsFt9NpYEA== 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=TvpHhBx6FH+0NaUZjlQg8u4oBnFWv7XJbgY107AnK8VPjuFScH6gyCVCGMxHBLX9EvUsiXWNhWvm9QqMKaNquC2yQ6aMHF10S89DmFXF6QiViXCNpMYM3GJzeWVdok+7l0AbwBYO8u4KDL75MBHhkmBAGpi5DHCvkWRO1iCpC4VEMLr3fFpJeLFN0p4tnsTLCTMlLe/vY9YS0ea7VZMM9WNi+rJQJhDrHQmZ+bkaG24xY/rm0EOrV/gOdqk3ucf6VryutrXZyrxKHD/lzodHANpn+TEqKdnvvDNtExDcfNtww812kbYAihvXwKAx4PNNUTfzvUYWvVEDuDB351jhsQ== 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=I1N9P48omYav++AgF54eQfEc8J/DsRz/ys2wfPAr3STPJPHdq2JuL9lTd+O6PP7DsKSmTuV6UX+Fq4ik0g/+7XsNRWnw6h6oIZif8FRynUFiHC2xh17MvtEvqSn3G9BIssyxkLrBluuxAdyQeKhkOdcmCAW9g5fpT6iFqe581oM= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:12:13 +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.3153.031; Wed, 8 Jul 2020 12:12:13 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 06/14] aarch64: fix RTLD_START for BTI Date: Wed, 8 Jul 2020 13:12:06 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0237.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:b::33) 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 LO2P265CA0237.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24 via Frontend Transport; Wed, 8 Jul 2020 12:12:12 +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: 3373714f-66a0-422e-2c97-08d823382999 X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|AM6PR08MB5173: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: LCPn/q5a/5uCPyojPwWmELLYsVK9j/EqE38Heef+p3eQyEIc15qwPpkkie5lhVagqxaanri1jq5AOXkYOYn8oB3BHjREPzqmk2dWJLyT6xRE8CwMQh6RIzPEp/KQfgKtt8zg/5VlhCXBO9EnSQDsrygz601FVBmjDi0BD5DcwfYHyHHZ3xfiggCUsu/YydMp9RpqPfXdSQv4IcwPUAgehTaOTlXc5JW3XLV+N19JYYkRxdmh5t6JzBflRRW0BLoPmERu3xpoPUjh5k8hf0x8xS5uE62WSE1L0nRBnXAbUHI4Gvg2V4C1i8zAxYYCGthwxn98NLWUO3vG2Ws3/eSqcgQwB5F/s4F7rNIThnzP2L7x6lhopFe1z4RSc63ujhCafuC8d7/LH4GbNq+0kzcPcXLuBJD/Iyq3/6/GywQP/xA= 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: JYV3lfXU9Hdyrncy6Gqe9sX5TLzCyYSqjlIWZBhRIU62U3FXOVGa2jk7S8AEFVUkcd9vYK4NkB8rYf4oh6Dd/X6z06Tcix4hvuNEoJ6Re75icPlYUR0LOklEDXMkqyima3fmdID0fjo2VZhn4Gd68NzJYm84OblVeV+ONLW+6ai98GCRlKoDEiMBIXVcyAIVMKQjMzwESYbO8c18dCE+faZrT56ve3EfpgQlmCCDGYo0fp9Uv+nJE0wh3sVDyyz3AAIvfjQ829Q7gDx4MGI8j1U+iem+cR6qHvD5R4kTurDln0MGRT28NSmI7ajdThmUOlqSD+M6vNa3/qWaq71CLmHnCwqtFy7kEPFoE7VQwOGi40cL7HkuuISTYDBb/x4gi+iqpopoGpxuHmz5ECgVjuimCjOXL7MzmbLnBmUVNMqUNQTwQj5Lq6mNUrVhuoTYUfpx1dCxI6UwEFGNDxNMtnFH7QEZJEc/Td116ra6DrY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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: DB5EUR03FT049.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)(346002)(39860400002)(396003)(136003)(46966005)(356005)(26005)(81166007)(6506007)(44832011)(2616005)(47076004)(5660300002)(6666004)(478600001)(956004)(70586007)(70206006)(82740400003)(83380400001)(82310400002)(6916009)(336012)(69590400007)(86362001)(36756003)(186003)(6512007)(6486002)(8936002)(2906002)(8676002)(16526019)(316002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 5f96cd98-4b20-4316-88b1-08d8233825a1 X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8jS+veCH8e3GNTQZsKCo/23AlsdovCF1rRn419JOggxyedYsaP92dzXFE3H1V4DmTGJFmT1NhC/3qQ07ycp4PZRlxKu+ZGbIx9jbnYbABBVpR1iE948wpNkIj29kRDh0u4ojSp5SrPYqe4yqrwoWZAB4cpP47nU+fF+BrCzMIe+kVVflx0gZJ3hnakzjf9trFAsL+BpQ6yE2U3yLUhsl3ZXWsCNmWgyZX2De2gKn1BPySVZuejcof6Bn5/lmRxAWvM436HjPsuds+0ozKqlzSTz8gFmSGBXEAxDK1bqc6Lfz01hxmW7aBHSE4udlOhQHDJrKhmEWLULzerjFV6Yn+DRxu/14yeLNK+BGAQLBOLtzqn1BMRlSQJpsGUbYL/6qeTNfKJjtPIfsiSiBxeJQoLklNZQ3odMYZ8R+CXZHFp7mq1ttiUiG2uX+OCrpGsMRQuJ68ABjpOBB0okiaHMsKw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:12:19.5890 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3373714f-66a0-422e-2c97-08d823382999 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5173 X-Spam-Status: No, score=-16.0 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 Wed Jul 8 12:12:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39971 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 6A84338618A5; Wed, 8 Jul 2020 12:12:43 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10042.outbound.protection.outlook.com [40.107.1.42]) by sourceware.org (Postfix) with ESMTPS id 671AC386102B for ; Wed, 8 Jul 2020 12:12:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 671AC386102B 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=OA2tRNMznIX6Zx1KFN/4pCUCPNqeVaHPDf67jh+ZYDI=; b=ZQiWmcUZMeyfcjWtXPFs57H94ujlm4XJRVU3GLKWBXa84sdowvQMjd0HKrewTdlb3DVnkl2yi040Y0+AV8fG0lJMs6W6DJmravj+HDCZ+liWyg4TY1mCr5TZpbPWQcWvjgm+6TsWg+lM5gVwz+hu5kawLjl6uUWw0LdefzYZR2M= Received: from AM5PR0602CA0014.eurprd06.prod.outlook.com (2603:10a6:203:a3::24) by AM7PR08MB5431.eurprd08.prod.outlook.com (2603:10a6:20b:10c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Wed, 8 Jul 2020 12:12:38 +0000 Received: from AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:a3:cafe::ce) by AM5PR0602CA0014.outlook.office365.com (2603:10a6:203:a3::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Wed, 8 Jul 2020 12:12:38 +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 AM5EUR03FT052.mail.protection.outlook.com (10.152.17.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:12:38 +0000 Received: ("Tessian outbound 114f46c34313:v62"); Wed, 08 Jul 2020 12:12:38 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4298853517d09933 X-CR-MTA-TID: 64aa7808 Received: from fe98daa91a0c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 09E11812-DE31-498D-844E-19ABFEE74090.1; Wed, 08 Jul 2020 12:12:32 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fe98daa91a0c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:12:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CMIlj45u30T4b/Bj0/Mp6mrQ10GQ8RPmWhannUIJ9Y4QnbDxG2/G32nkX9xF5ulqyZmQl9cVl+8i0XXRCQ9V85XOB7FxkrWV4NHMlxvzL7s7/4drKaxz2e2LNyafDnRSl/DhLNZvz4B2DIIkTc0yxG3POz5etQfIi66WIhYNrAItv/apYLrMm5IEM2JErpaUR+yWn5kC49WR3H5oSiJOVwBYMxuAnIssrjEuQuaM7mYY7OMxJ4SVZgkI/UwbgDclUh5WxOCEnyaQAqu0w917SEzCJMm7U4IcatxWfZPe7wmG74p5yLQXwq0Okogg4wFQQWtylvk0wQJpqGKlARaQIQ== 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=OA2tRNMznIX6Zx1KFN/4pCUCPNqeVaHPDf67jh+ZYDI=; b=GaYTZ5ZKyRyatEBY3mW19aX1Et/tf4XKLjA/kMtbAMjNwXEtpdiu/g+owqsmRCArzA4gj+EDuO1lLA/UxUNwmsKwhJJ1sFe76NJsSyWeiXngHNEk4I4htAy1RmsrENELT29o7GMMhQfthjPg9btnxZNMr0KDnbMFrEngD+lBFuWH2KTCZJjm8MifxBsOAl3THvPnZp8ZBkRkW8XO/1LG7OC1bBzbzoJq71VfzHBQPTkcfjsqiZqoiJiwI18HJ9hgnS6JCH4LEk3RweOvSLrNKQ+GhALaLTGdPX4jv6vjAusnsCRelP+bsanXveiLPnnR4X/g1Z4znbnnSrt9i1zWDQ== 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=OA2tRNMznIX6Zx1KFN/4pCUCPNqeVaHPDf67jh+ZYDI=; b=ZQiWmcUZMeyfcjWtXPFs57H94ujlm4XJRVU3GLKWBXa84sdowvQMjd0HKrewTdlb3DVnkl2yi040Y0+AV8fG0lJMs6W6DJmravj+HDCZ+liWyg4TY1mCr5TZpbPWQcWvjgm+6TsWg+lM5gVwz+hu5kawLjl6uUWw0LdefzYZR2M= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:12: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.3153.031; Wed, 8 Jul 2020 12:12:31 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 07/14] rtld: Clean up PT_NOTE and add PT_GNU_PROPERTY handling Date: Wed, 8 Jul 2020 13:12:25 +0100 Message-Id: <216a0255dddce1487ae556e6961bc52bd397d35f.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0140.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::32) 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 LO2P265CA0140.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:12: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: 1ec5ded0-d74e-4a1f-c71d-08d8233834ac X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|AM7PR08MB5431: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: +n0PgbA68TA7qwnS/1J/Zd80890yP1T2HiW1cQI26VrSqQWNk4+Q5Zlm80dLRBhDx4Ueg8SRJXoRhD68BGWgsJfb4NQqyZQ98r5sYXl9Ai0R9qDQvjWHtSmt98ABEkHMUV+D4CKGCc51OnpmKfP2W2nqv/nkrBfNBNva/cKhHqA7HfNXxOZkAgvtRCuCl8vUn+uVrAl4MTT5PLfSnaSJKNPzDoCZLZODMW+CEgMvVilhfNTLpnoXmpN6bm8GJH0spCALBkSVw4D4F/VaF+REfbGDIyRViIFJXJt6vcWVUoiAomPZV3EQYCCvNLCBuNSk/IiVnkPcP8DZ/IxGTToakNdvy+cMyMkLIt9qDlDhuC62p7HvuQ0tQP30dLSl1zOBPXzksONH9ASfFYn9iBqv4tuSZNzwffioOtDzPT9f47w= 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Ae2z+LqHw3TgaDnXqE5laZqp+5F5H/N2L+yJU8Q3EB2hdbBtlqSxhjWUXPR4wG3SAAWQdA2XbhCKhm1wbFtNglMGHOdWLZRsPTQzwTs7J3nuHOlUK7KV2j2zxAaME++nqlIYsId/taeVqek96K6wdz2LLyeRqW/h8YV9RwvY24EBxb3rdY0h0iKUtwQ8F+IfZiAp0GX0LAcf5S4BPnbE6i0FbMrnc6aieleoEJamSs2VrcmfHuQvyp+UyDkJMI20hq2rqMaKRc6w5PQ5Pl04rktaXOnCo0r0ldp/PsZpBGJ93anlcfS2CV8fLm2o2X+iHHKf5B4SV+wrwBxCxHKbt334y7oVdbkmr5jW86FfNX36uIaOxgXhqgrB/VEzdAaO2y8iyuI4dem4j0CKEi7g6aMCVd8Jaq2vJdII6f9I+ZeBfz+3X1o30LY58CJAmcEAs8MhcItzX6dsyfFCo7NEEeDtTeDVgKPherk+vbw1tjU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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: AM5EUR03FT052.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)(376002)(136003)(39860400002)(346002)(46966005)(8936002)(36756003)(6666004)(5660300002)(69590400007)(44832011)(356005)(81166007)(8676002)(2616005)(36906005)(26005)(6512007)(82740400003)(2906002)(82310400002)(336012)(316002)(16526019)(186003)(956004)(47076004)(6486002)(70586007)(6916009)(70206006)(478600001)(6506007)(83380400001)(86362001)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 5d6a57c7-c44e-4eb1-00f3-08d823383046 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NS49F9kTwDh28Ay117NXeemXJvfBe7SOYTSJjsr+GXSMQS2MU/B6ZXUptFHO1L8HIGdxdHsmMPpbMbtImgyaRgyb9Al3oG4pWZByjArKLf0dWyabUBbxFv+VWhSGYxgujYsrIANF1qSovEZ13OyR53LQ5ilYXqzdIQmQcRsOf8Flo2k3Evsz9eRTNIV9qRoxGHrScmHrdJqs+cBO8tgvLkvRq6ZalofT6NJ426CxNdte+PSBKUVphr/CAUBkpZKNsaB9Z/4zLUg4sUv6FztrJhip4/Et8EkYYFo1giDN+Wr/MHxQ05TjUUlbDx91HBArnvKK5KLajE06Dlx7JeRq6/pksfIxkmhAK5UnG1JdT/WjMcEvAVFQJbOnNoRTbffDNJtHl+W0bufpxkYUW/XWWXJkNcMPu/PBMW3/ISs0BKcgD9dYNiwC5/XuP/jdL1gTx5FfOvZKIEBtFHaXJu7hsA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:12:38.1034 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ec5ded0-d74e-4a1f-c71d-08d8233834ac X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5431 X-Spam-Status: No, score=-16.0 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. Invalid content is ignored, _dl_process_pt_gnu_property is always called after PT_LOAD segments are mapped and it has no failure modes. Currently only one NT_GNU_PROPERTY_TYPE_0 note is handled, which contains target specific properties: the _dl_process_gnu_property hook is called for each property. 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. The old _rtld_process_pt_note is removed and _dl_process_pt_note is always called after PT_LOAD segments are mapped and now it has no failure modes. The program headers are scanned backwards so that PT_NOTE can be skipped if PT_GNU_PROPERTY exists. Co-Authored-By: H.J. Lu Reviewed-by: Adhemerval Zanella --- elf/dl-load.c | 94 ++++++++++++++++++++++++++++++++++---- elf/rtld.c | 14 ++++-- sysdeps/generic/dl-prop.h | 23 +++++----- sysdeps/generic/ldsodefs.h | 4 ++ sysdeps/x86/dl-prop.h | 47 +++---------------- 5 files changed, 118 insertions(+), 64 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 06f2ba7264..e39980fb19 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. */ @@ -1145,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)) @@ -1188,6 +1251,21 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, maplength, has_holes, loader); if (__glibc_unlikely (errstring != NULL)) goto call_lose; + + /* Process program headers again after load segments are mapped in + case processing requires accessing those segments. Scan program + headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY + exits. */ + for (ph = &phdr[l->l_phnum]; ph != phdr; --ph) + switch (ph[-1].p_type) + { + case PT_NOTE: + _dl_process_pt_note (l, &ph[-1]); + break; + case PT_GNU_PROPERTY: + _dl_process_pt_gnu_property (l, &ph[-1]); + break; + } } if (l->l_ld == 0) diff --git a/elf/rtld.c b/elf/rtld.c index 882b070cc0..f4c2602d65 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -1507,11 +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; - + } + /* 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 6b0f2aa95a..f1cf576fe3 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) @@ -36,17 +36,16 @@ _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) +static inline void __attribute__ ((always_inline)) +_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) { - return 0; } -#endif +/* 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)) -_rtld_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) +_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz, + void *data) { return 0; } 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..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,48 +144,17 @@ _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) +static inline void __attribute__ ((unused)) +_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) { -# 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; + 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); } -#endif -static inline int __attribute__ ((unused)) -_rtld_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph) +static inline int __attribute__ ((always_inline)) +_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz, + void *data) { - 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; } From patchwork Wed Jul 8 12:12: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: 39972 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 4194B386189C; Wed, 8 Jul 2020 12:13:04 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20075.outbound.protection.outlook.com [40.107.2.75]) by sourceware.org (Postfix) with ESMTPS id 4DA5B386102B for ; Wed, 8 Jul 2020 12:13:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4DA5B386102B 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=8Owb/ai7E15+VDGyV7CdP3zOD2mu5GN+coBzjp5WgHI=; b=Pq/P+9XP0mvRiBfeZiFv5nc2Yiqfy9NA5e6NMopGfJCHetMfYTat5UhPyMeqtX1niPZmT37kEAwQ8m6X/mWFvzkfUUlGWYLLCS0NTMqV+1oROVRzbQNP1f6kznTUbgFctIuXSRwYq3cUfloiST733lVRtzpiMxAQYRJt4w/AThE= Received: from AM6PR04CA0072.eurprd04.prod.outlook.com (2603:10a6:20b:f0::49) by DB8PR08MB5403.eurprd08.prod.outlook.com (2603:10a6:10:116::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20; Wed, 8 Jul 2020 12:12:58 +0000 Received: from VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:f0:cafe::b8) by AM6PR04CA0072.outlook.office365.com (2603:10a6:20b:f0::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:12:58 +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.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:12:57 +0000 Received: ("Tessian outbound b8ad5ab47c8c:v62"); Wed, 08 Jul 2020 12:12:57 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d85f6582fe1291e4 X-CR-MTA-TID: 64aa7808 Received: from e4b7635fea74.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 997CFFB0-BD70-46FD-A89F-1626776BCA09.1; Wed, 08 Jul 2020 12:12:52 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e4b7635fea74.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:12:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cdPjoFq9tCDMWMDk9OH5z0nN2ywl4g30LGpYx1sc0S7wKIiwjParF658DHTx785OX98T4pVoknWf79pprlNNGzK1cqHYzgQmkFaxHGNdoxuvbamxsJ0ncWmwL5JJXD52c++ciOiD0sknhreqUXiOVTJTeWcbOCE+xeOfpGAtG+cRuHMyCLAntaY014Btsf1ytOhLlcl98lHfyfKo9EvxMIWQ8ZYa7o7390LS0pvra1xPHpRKQzJ6veIddPyTZdab3Kk+TOSGcizmiM5auBJJ73BEyLg848LyEIWCZAmtVeXpBBwdw+RQb4+UTpnlV+3GHEb+d/CPF3GD7vzEkAF0TQ== 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=8Owb/ai7E15+VDGyV7CdP3zOD2mu5GN+coBzjp5WgHI=; b=ZHTi2NGHrWqfJTOa6q8cfBYjgP4Ph11CgwCD+hEpiRQhVzMPhQ50gnhc04O7OJzDDGNmuCQDXImaZISdmEaLUgAmTpcsL9lLE5U6Ky3LskYAsPO4oDOFFOEa1kiU/dfhA02XAMZqP8jwDYS4FPJQ4GENlw/QIGiRWEcOEF5NsrRPpRwd8FS02K4SJ7GlG329sY5mJTDoYfS1VjGCmA6tmJaKFj/KBcoG9L2pstnmGxqOO8AsszLuf6OgBpc+XE9SOjxeNaB0ndHE+bRqvF8xYRFF8r/6dRLg4N53ua8EodNb2rPVU+iRYs0+F1YZuSAwZYkG8q/1lmx5GMl6YQmDmg== 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=8Owb/ai7E15+VDGyV7CdP3zOD2mu5GN+coBzjp5WgHI=; b=Pq/P+9XP0mvRiBfeZiFv5nc2Yiqfy9NA5e6NMopGfJCHetMfYTat5UhPyMeqtX1niPZmT37kEAwQ8m6X/mWFvzkfUUlGWYLLCS0NTMqV+1oROVRzbQNP1f6kznTUbgFctIuXSRwYq3cUfloiST733lVRtzpiMxAQYRJt4w/AThE= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:12: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.3153.031; Wed, 8 Jul 2020 12:12:49 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 08/14] aarch64: enable BTI at runtime Date: Wed, 8 Jul 2020 13:12:43 +0100 Message-Id: <910a949edf217253d82ceb238479e45c5d1738ff.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0111.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::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 LO2P265CA0111.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.29 via Frontend Transport; Wed, 8 Jul 2020 12:12: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: 57b14a31-8f7b-44a7-31a9-08d82338408e X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|DB8PR08MB5403: 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: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: CaIl0FLgqv4ceX8tvRB1vhzyNEYT6S9Q4E29N7U9lx05kRgYFr8VaIO62xn3/1U2NP7SjQ0K0ufqY6DL4i7nOA5O7S44GLO4hh7LNaORWKRZMfnqYbWbUT7qBPP7I3lbwyYBSCpeDsjZD7HgxSu4HW0cwh33f2QZ88F0LWiZjvJ4nXlE9Z4Jdth1gMqph2G+MLoCINvOuHDsoSZ14fqVIg4i3sJzrfn4gFQC3bjGd7lHcZ6sE1kwuK4BL8w4lS9Frzeuwtq73TL5uM2K9FKE9l51ZBpQtOjONYhufsNX0GTZYxqHT+Ah1nfddwkAOKimBCxHil3FiAUBShRr/oXfji8VhdvpRxcZcQ+oYnb6J06SUziQYfdBMTUfs47BVXcW97rpmQv58OEjNfBIUwdt+GDHRoWVsv9fRLIKzM5AcvHfiVEzT6QERq2YPnrfQOVgKhTtixCOvBTYAADY1aEhwqHGZTsL9153sk9idzBlEnuG92wc5fl1pB8BCXrr6DoaW4y720AXElMJzX94rIyPZQ== 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(4326008)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: IW1jkf8m/tplV6m+mP8rfRvzbmpEEPLS0dranjc3aiJ4C1pWCoq1iAEEc/6fXPcboLvRiMW8bayz2SjpsMtnBSodUJSFwj1DM8sTUxC+wjCvdcnS9bRwyMS00rJh4HWLdb6oDjdaDfaxaZ1B0ou2+4k9GTRuEDHnwBI1HK7FzAW3CFr3W6d3QGy/CQxjyw41I4R6OYbBdDXwt/vSZuIR4ncS09ULcO1WX7eUKUecmWih+zs2MKl+L3X370W/60F+ldxxPq5bx2sZdAIDZ8rSApRNt+VkEgO2cI3bXzUyv6cfgGw37Z4igj7dKFS6AdsfiB8VoJz4Qe1uLwFyFrQODQaAjjY+83z7o1gGLbQVWTM+6aGF95oSptk2iuVhLgLUL+03ADKHKkgAOCK+hFJqKKFU75w2O7zXQuMhVC212/Ycz2svC8z4bsX2Gs8tACN6V2hxh+k9wZjnOKXm/4wto8LfS3IsHXBxjv7f/0LqDng= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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)(136003)(346002)(396003)(46966005)(336012)(6506007)(956004)(186003)(26005)(2906002)(6916009)(2616005)(316002)(36906005)(8676002)(478600001)(8936002)(4326008)(70586007)(81166007)(69590400007)(82310400002)(6512007)(5660300002)(16526019)(70206006)(356005)(6666004)(82740400003)(44832011)(6486002)(47076004)(36756003)(86362001)(136400200001)(2004002); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 1d61593b-a675-4493-deb6-08d823383b3f X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bvBhIdld+KnbWeT2H+nQQ7rgeVDAxI585S9wjHKB9nJEtU2d0quB5pjM8OZY6B2ZIuhP7nc/QeCA1zh5Vbgiy8KOQxW2pf+Im6haUkFV2BmoR6WYIu0Y1s7pLvl0deyBgD8K4ydKv+bPGMA3jd/CAO6PZFOveRgNNpx0Fsi7spMb9s7nQ8bPbRoxyXxSK5DWkju6MNCNx+brA0AljpGO/h31LBFRHLj28Hxgd1Y42FzAj66sNge0REcdmVzzmCYJ/qZ5/PVYhvXk95pBGwfUVOTevyP24YmgHQJ/9m/fycbBLEWIs8JyW3fDmhLc3eU/XH4Rp0GyP4mYnnjTfXsMx+TLbhiWudPgyt90EEcuwCNcBVfgSBSj79aCtOBUTmG9jC/IcV9VuQ9viEWm8sm51pcYxQP9d5zShJ4vQRqehQlzzbnja2hSfBwl+YsR2ztJhJzjVbNFidauv0h5imRKG1mRh3+Wg9pPdeSdC22xdd/PNLuYSK1Mkkg+C+jgVVwZ8ovBvFeA48AzXccQ0LPh/Q== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:12:57.9617 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57b14a31-8f7b-44a7-31a9-08d82338408e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5403 X-Spam-Status: No, score=-16.0 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 Reviewed-by: Adhemerval Zanella --- 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..965ddcc732 --- /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)) + { + void *start = (void *) (phdr->p_vaddr + map->l_addr); + size_t len = phdr->p_memsz; + if (__mprotect (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 Wed Jul 8 12:13:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39973 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 A338E38618D4; Wed, 8 Jul 2020 12:13:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150042.outbound.protection.outlook.com [40.107.15.42]) by sourceware.org (Postfix) with ESMTPS id 476EC386186A for ; Wed, 8 Jul 2020 12:13:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 476EC386186A 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=5ze93BfbLbcuEm+Zn+c2UTV3oidTGH6Hh8zmKEVxkyw=; b=SnIoW9DmzhmqNFy2b0QTla9PUeTTFcMMf8iVyAiKfOVMf9ejmqAKIdlqsSZbli9+xtY0OBVhjinc6jHmMAxODN28ICYQHMR1q6awrV/SzBgoCeHehBc+jy6G7ngG4Ak0m5Ggi2aHVq4fL490rhnyshuH/Yq0+n8UC+mzjPZbptU= Received: from DB6PR0202CA0040.eurprd02.prod.outlook.com (2603:10a6:4:a5::26) by AM6PR08MB3077.eurprd08.prod.outlook.com (2603:10a6:209:48::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22; Wed, 8 Jul 2020 12:13:14 +0000 Received: from DB5EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a5:cafe::7a) by DB6PR0202CA0040.outlook.office365.com (2603:10a6:4:a5::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:13: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 DB5EUR03FT034.mail.protection.outlook.com (10.152.20.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24 via Frontend Transport; Wed, 8 Jul 2020 12:13:14 +0000 Received: ("Tessian outbound 114f46c34313:v62"); Wed, 08 Jul 2020 12:13:14 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 63913eee4b3d760e X-CR-MTA-TID: 64aa7808 Received: from aec26546d3fc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1ACA8C33-BBDE-4582-8DD4-0189447899CE.1; Wed, 08 Jul 2020 12:13:08 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id aec26546d3fc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:13:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AOX8rvSHIrzZs4NeN2FjBESg5mOpJ/8Iahl4ioe9QxGpdjGDnJWDe0/ik8RClBs1ksj2dxFwBlWIJknMrYycjQvVGvORufxUN0Qvts9snb4SVm+jC8fxLexE5g5O36XHI2EX1cI2BoHxOEtbp8WYDJ2cwzN6IHO3bIRvl0Y3kr/RJgROGkyfxf9lujyb147epvY734BUh9zkatSPvre/zMWN+z7W6SHFkYLdRAQ85V8XuOIfJr1eLlKa1e0PGdloH84Pxwwjn57Vg17hcUmfp09NprheUJ2TzEbDTG/2DT6qhBzLfoDLRwLlq1vIyWVHuhx7olH/142ep4z0JA5sKA== 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=5ze93BfbLbcuEm+Zn+c2UTV3oidTGH6Hh8zmKEVxkyw=; b=PAkd1IE+lipM9FVuQHkV12v9VuYY/9w2qIXA3UaudsKqJpRI7DsT0QPsxafEIpzfmrUJICg2pPSnD/TZbusFwYekZEzTAJjMfBrAzPNAFQ9tZ9E1dVEzFhco1Hv+zXSsuukQJx0X7++D0jiS9uevX4BF+Jub4efNEZ/dQrdv67OC19x0k/pf2YVbkm5lrN5xmbM6DesOlC5f4OJ+hrRa6fwNTNIMf+bcv80nnpl40KA66WgWjNa56zlb6IPQhjbjmfq/McuqsMcrsAemKhCbUSnIp8WVXddlEnKEf/HQkYEXMdQWyLH4cBtclfpYE7NuiiYjn3YGfSNnDa82D3SbVA== 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=5ze93BfbLbcuEm+Zn+c2UTV3oidTGH6Hh8zmKEVxkyw=; b=SnIoW9DmzhmqNFy2b0QTla9PUeTTFcMMf8iVyAiKfOVMf9ejmqAKIdlqsSZbli9+xtY0OBVhjinc6jHmMAxODN28ICYQHMR1q6awrV/SzBgoCeHehBc+jy6G7ngG4Ak0m5Ggi2aHVq4fL490rhnyshuH/Yq0+n8UC+mzjPZbptU= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:13:07 +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.3153.031; Wed, 8 Jul 2020 12:13:07 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 09/14] aarch64: ensure objects are BTI compatible Date: Wed, 8 Jul 2020 13:13:01 +0100 Message-Id: <171c576f3a8d9de36996721b8bab2884499c648b.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0064.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::28) 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 LO2P265CA0064.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:13: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: b295f6d2-3851-4de5-2e30-08d823384a0c X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|AM6PR08MB3077: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: AjQCLC9sVRauf+YErwBULoE22PBTCk5ThrkiXafxoZr3EjXzSO0dcQCj/AWHrDm449fFo9pAbC8gu/vKMHHGU6BRCV5evMEz0uPD1ojpkZo8czJp1B7H2EYhhwiG2Pwt4nEv2qhOSyNLMSACCvEkuViauSocIUREqywGrqTvnnVCPVcAps9QLT3D29HJLX/S4hpaq5jDR7V5EEhIrNGuKj5EVjwkWI2GFWJOtFwzHSZGEqTeYtOjQYyzg56fY6XepbCZ0l0hyvEMTBsPIHybZdI+nOwdgGoeC/BG4w5mGIKSNvu9NypJWP3EBu4Z8ArQpOcnR/JgC0W7WDcncDM6DifjYG8M5ggsheTj7m4vd8hLRNx95we+04kYogjO9VPPC7C0j/DPw5Mu699p9lVXIBroqyIijwoanXoiqtijY0Y= 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3PsV4DKEOQB+kEGbTc34l7sMxwSFVbv8Ll5XnQ989v3s4JFLycS/7XFoyhOwlGgnGSucXaciMe7VCeri5tg4BR3UglpioNHLAyXl80Zxky3hN4/9X5Q26j6UWnaALZX9T0/zJajW0QMS1tfuKbMvpC+X9EI04RHKMdtOLP+9NWWu/Po5BnSVRLzFRnJzK+YQaSs7V7kO7c3X8Cfn/WxoSrvdPoNg7cfYOrvFD6pt6X1Wm008d8kzcoLaYuyd5ZUN1gdWYECQ3bTy6LEimV2bjpOy7hNGo7F3XUSNclN9oE2dFTnVe8qlowjpH/bkDqAAkbxDNxrnDTJkKxbpKWAX8KNMMOHJhqeJSq2bQqNLWCA+Q81YvSJDBR9PnKvAfgSnyUVxLTnmNTogG4+hpzgFf452Fusc9VIIijEF71ty4+qLHaqlMbdcvqVAAHywE//d0w35WFROM8TW89v4dUUevBZRVSL4ucWmfsl1gHo2Dg0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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: DB5EUR03FT034.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)(136003)(346002)(376002)(396003)(46966005)(82740400003)(26005)(6506007)(6916009)(6666004)(36756003)(83380400001)(69590400007)(47076004)(70206006)(70586007)(2616005)(6486002)(6512007)(316002)(8936002)(81166007)(86362001)(5660300002)(956004)(16526019)(186003)(356005)(44832011)(82310400002)(478600001)(2906002)(336012)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 9c3dc99f-8fe8-4599-a7e7-08d823384616 X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yspg4J2JACb4mBObjPozegKWziyI5sGD+VYCgYPr56yChAre1PAQ+d5upFZ52B618qnXZcKdOlGgWuuiO46c10eYTLicrWAypr2GvxZwmo0bikFUtpuXYBlTqFvSqY7o2bs3iyt4xiwX0YoFY48kiRVLrVA/LIdNqdUuEaKK8Kg+04J0AoYlioLrGHJE+jlaSMUZD1aZ1zTIUYGcHM5X30Tg334wqQQBxfYbTXgXZkEWB4jz/ZMR9hyMEc5QJW/0Kpo+DVWRX33j0FhG5iBSn6U805/PWaoxAf92cT8QsqaLnqD8bpbBgAXSsFCsqoVZSmxOSxJydg94NGLDKRMojJhl6smEpg2O7NUjNYe0NQ6xYTiLYRamPsFQM/oVMLddNbUulnDv0kwzsuZDtvjMgw3hOpck0ZUkVe/su+ygGiZrAtIKydyVq5p4tL+2SiVOEDPN114nfwpJF6jFHpD+Qw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:13:14.0318 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b295f6d2-3851-4de5-2e30-08d823384a0c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3077 X-Spam-Status: No, score=-16.0 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" When glibc is built with branch protection (i.e. with a gcc configured with --enable-standard-branch-protection), all glibc binaries should be BTI compatible and marked as such. It is easy to link BTI incompatible objects by accident and this is silent currently which is usually not the expectation, so this is changed into a link error. (There is no linker flag for failing on BTI incompatible inputs so all warnings are turned into fatal errors outside the test system when building glibc with branch protection.) Unfortunately, outlined atomic functions are not BTI compatible in libgcc (PR libgcc/96001), so to build glibc with current gcc use 'CC=gcc -mno-outline-atomics', this should be fixed in libgcc soon and then glibc can be built and tested without such workarounds. Reviewed-by: Adhemerval Zanella --- sysdeps/aarch64/Makefile | 8 ++++++++ sysdeps/aarch64/configure | 2 ++ sysdeps/aarch64/configure.ac | 1 + 3 files changed, 11 insertions(+) diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 5ae8b082b0..7f82fc055e 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -1,5 +1,13 @@ long-double-fcts = yes +ifeq (yes,$(aarch64-bti)) +# Mark linker output BTI compatible, it warns on non-BTI inputs. +sysdep-LDFLAGS += -Wl,-z,force-bti +# Make warnings fatal outside the test system. +LDFLAGS-lib.so += -Wl,--fatal-warnings +LDFLAGS-rtld += -Wl,-z,force-bti,--fatal-warnings +endif + ifeq ($(subdir),elf) sysdep-dl-routines += dl-bti endif diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure index 70477a7fa5..c637540436 100644 --- a/sysdeps/aarch64/configure +++ b/sysdeps/aarch64/configure @@ -210,6 +210,8 @@ EOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_aarch64_bti" >&5 $as_echo "$libc_cv_aarch64_bti" >&6; } +config_vars="$config_vars +aarch64-bti = $libc_cv_aarch64_bti" if test $libc_cv_aarch64_bti = yes; then $as_echo "#define HAVE_AARCH64_BTI 1" >>confdefs.h diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac index 798f494740..2c2817514d 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -36,6 +36,7 @@ EOF libc_cv_aarch64_bti=yes fi rm -rf conftest.*]) +LIBC_CONFIG_VAR([aarch64-bti], [$libc_cv_aarch64_bti]) if test $libc_cv_aarch64_bti = yes; then AC_DEFINE(HAVE_AARCH64_BTI) fi From patchwork Wed Jul 8 12:13:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39974 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 8639838618C9; Wed, 8 Jul 2020 12:13:38 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140044.outbound.protection.outlook.com [40.107.14.44]) by sourceware.org (Postfix) with ESMTPS id 4FA60386186A for ; Wed, 8 Jul 2020 12:13:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FA60386186A 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=8v7sJxWvUa6D/3QYiFKUMbVS2pVuHK7KRe6W/votENI=; b=mSr2x9IhaVp8n2KHBL3m01pL5lYISH7gR8sEQHLaBOB1gC45j9aa3dIlPmpPyaIxgp+Gfb5Vgz21CvvHJrYDtORZEj6n05ya9tHRJt5GnXKhe2y7burZwIJ7k8u0jrs2H4VEbCuANpmM/hM9XQxged9yYE925+I85DSDgk33tRU= Received: from AM6PR08CA0022.eurprd08.prod.outlook.com (2603:10a6:20b:b2::34) by VI1PR0802MB2463.eurprd08.prod.outlook.com (2603:10a6:800:bb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Wed, 8 Jul 2020 12:13:32 +0000 Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::3c) by AM6PR08CA0022.outlook.office365.com (2603:10a6:20b:b2::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:13: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 VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:13:31 +0000 Received: ("Tessian outbound f7489b7e84a7:v62"); Wed, 08 Jul 2020 12:13:31 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: dc873d991303a172 X-CR-MTA-TID: 64aa7808 Received: from 5320e664d902.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A3BC7C80-2231-418D-AACE-DC8516015DE6.1; Wed, 08 Jul 2020 12:13:26 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5320e664d902.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:13:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFINai/zdKeh+pvDUYY/cpZ4IVVuxvf9+Qbvq6NmZdwe4FQJMaAFnZ/F+XcAWNgWTAg5IudpnzUNG96wEXqC0ySpEQrb7r6cG2tYORz/JpByryG0a44Ra9BmTA3W1aWilYhXJttqX7ztgCVTQ3Q6pq8sgzOG9pDJ58vMxvBgbXmPAuur31oPTcXeCSg69PsXPmtcZe78EJ5GDAqMJl328N2Lmf81/yjYb5ITFXLbfuw3BNoFJ86BAXENXikMUQY8iIqg5rxvA04u7qdQJr3hMgzum/EdYau9Qd1I9W1imSkxbcwEzR0uwhFv6RLTT1S369zfwhwHFYQiaQllVm12mA== 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=8v7sJxWvUa6D/3QYiFKUMbVS2pVuHK7KRe6W/votENI=; b=Q15bR/vLOxQf5x25DgxhedIQeD/nNRsDeadJYyMk3GL1vBNi5CSKAaIX6HwHQSvmVGmKKw7VIvjF4iKBM4iXJ03Q6g2lyO61u8v3cykt2g3zYgKNavdcxuOw4GNNFz2BCl5XZTMczshCz5Q+vfXuSLvmiIVXMY+cx/SpWIQLFgLHBXtw37Eqkrlrj9EUX7Z45MrETPDbzwGnVTmmKzIl/dovJO4vxUh0r9zW1fcO9MxDyp/T335/AKFOGJof6HA+i1wghd+k1UGYde8Zjz2fFq7/zQGytQVbFZQSlK0vb+MlMMbA9sBQmBPyIRFgZZeLgI3MG0Ssj4O2qb6T18RrbA== 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=8v7sJxWvUa6D/3QYiFKUMbVS2pVuHK7KRe6W/votENI=; b=mSr2x9IhaVp8n2KHBL3m01pL5lYISH7gR8sEQHLaBOB1gC45j9aa3dIlPmpPyaIxgp+Gfb5Vgz21CvvHJrYDtORZEj6n05ya9tHRJt5GnXKhe2y7burZwIJ7k8u0jrs2H4VEbCuANpmM/hM9XQxged9yYE925+I85DSDgk33tRU= 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 AM6PR08MB5238.eurprd08.prod.outlook.com (2603:10a6:20b:e5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Wed, 8 Jul 2020 12:13:25 +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.3153.031; Wed, 8 Jul 2020 12:13:25 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 10/14] aarch64: configure check for pac-ret code generation Date: Wed, 8 Jul 2020 13:13:19 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0310.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::34) 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 LO2P265CA0310.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:13: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: 9015c087-0f0b-4770-7fa4-08d8233854a1 X-MS-TrafficTypeDiagnostic: AM6PR08MB5238:|VI1PR0802MB2463: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3276;OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: WLASQ/lREoDf4TkHtHJD/+dx93xLRX0nVyVTBHNZ8IGoJYgCZ55QBJhgXR/FHohXpubT/k0e0xrYdGOSWO27vlxm/Cd1Jaf8Lg54OPULutmb8+NjmogFMvxqTkennppzgKGPj6Hl0v6ot1d8ZdejqROAszEgXI+QGnQVKPHtvxn1CN/+jrZtJZ7C3qEJz1Xk9LAotiI37vvnUR2uPSReTQNhDO3HBuze9kKnA0KpMpkpiuILdfq6HQ6W0U3dPOxl+6EI9TqsnhVDtl/9de+V8uYhkyGVjLbjl1SlGmHAauoHabaDjxad0vaIHbJqbxL7LPrpkdSx4bIsoBCK5zXGv8kJaVOBu5YTN9QCFw9OXji+oxCzzds90mPqGJudtkecBcsPDxr9VJbuwrhDVrmaNMcRWR5G40fIv+NzXZu50ow= 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)(396003)(346002)(136003)(376002)(39860400002)(366004)(44832011)(6666004)(26005)(8936002)(6506007)(8676002)(83380400001)(956004)(478600001)(52116002)(2616005)(86362001)(6916009)(66556008)(66476007)(5660300002)(66946007)(316002)(36756003)(186003)(16526019)(6512007)(6486002)(2906002)(69590400007)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: FoajxVOozmzzvVDK4NlNwi1RV7Ci+JviGp0zmwtbrXXr+aLGEek6kfUnbu9aDIZgiTfTfHcVLnMx/mmvWPrdwagXx+MbHBOATlht0a1GdCwErPZpcbx6zKLsWb+i/VpFIR8NttCKdc8vrgfMYXfRls7NAamO2zapNnv2ZraQh0K+c+sHv4xsc7NADhGW3zi7cqr5AmjsWXi/8AfUSu6Ibe3+g8SFTsyugbztbZgIxtJCIcx5UmfHLF0VlCwaJiXT4jlTKqjTyhFzs6kKh1UnmGZyw4ykjvPS758k3jqkcH+qN4KIWfMatVH5IEyLc4D9svGT14ix+QHEcL0DyAYOGAkFMwI9TW89Sm4DUgFqZxV350OIkP1ow22E2Didw7pc5mNBuAGylnYVI1VgFNNUg+DjTEZXx/h5+AlNwaZsfO6Eggzfjgu7AgnMgQLKg++3XsIvAwcCvXr5+UOJK/a6VHgiNjROVPaQG9GyKOMBZRM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5238 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: VE1EUR03FT049.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)(39860400002)(376002)(346002)(396003)(46966005)(336012)(16526019)(478600001)(26005)(8676002)(6506007)(44832011)(2616005)(956004)(6666004)(83380400001)(70586007)(70206006)(5660300002)(69590400007)(36756003)(81166007)(47076004)(356005)(82310400002)(6486002)(82740400003)(86362001)(2906002)(6512007)(186003)(8936002)(316002)(6916009)(36906005)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 1afae974-2fcf-44d3-9aa7-08d8233850b7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qMDRC8rJmZoZ3rVE1qyqJko1cVOuCypWJUbjuw6G5mDLNtSTVLzr5Qbr9y/uTAu83e2ObtLU3HTpePbCi+f1hFGVol4txnhnEcc7wwdGjsaHfgI5H51jMTL9R9CwR5h4DXIJaqmdrePYkeVFz2V/EURZQ2GEe81nWkL6lEXrF00djnB01WtVhotaXFG6W6Rp6lbO5MNuqff75TuK+NOMYtBZ2Bxs18xVjWYcJN/COE9URMnNnz1hoHvPSwVwtlejPPYSaJsWrUnum6NnUwGN56g5Eve4MLnr8MXyoGm91y/5OtkQ9+eGRNUG3UkD5IC6B42G2aDZPh3tLQATW2hFKXbAGffAJ5r4vgfzCttJOvec/MyA/037BNerYj0SIvybeyTrnXEJCWfHzVRcbOXMUYoqMFZqLeSe3HrJVp19HJRRBZrHe/TuxaT+dzFrdqJmKOEtBTuHVxOZFeQDdq9rcA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:13:31.6816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9015c087-0f0b-4770-7fa4-08d8233854a1 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2463 X-Spam-Status: No, score=-16.0 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 c637540436..ac3cf6fd36 100644 --- a/sysdeps/aarch64/configure +++ b/sysdeps/aarch64/configure @@ -216,3 +216,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 2c2817514d..8b042d6d05 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -40,3 +40,24 @@ LIBC_CONFIG_VAR([aarch64-bti], [$libc_cv_aarch64_bti]) 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: 39975 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 E94B738618EB; Wed, 8 Jul 2020 12:13:54 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20080.outbound.protection.outlook.com [40.107.2.80]) by sourceware.org (Postfix) with ESMTPS id 8C156386186A for ; Wed, 8 Jul 2020 12:13:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8C156386186A 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=Ou0mr1ZYvIjpsVVHc+jlGLoVyKIaBhqKOr6JSzu27RA=; b=x2t2oJJ7dBgb/CKABm0er3/g5LTuCYF9RevIL4lSsqa+NKtPcIefojjWCkwLkRv7unQ8zsvE3SGbykTq8ooSBV10YivnA7JlcnxKUG81kZKYlI/CAD4+NW+iRFq6hXL7SNdZID6jwpmadTF1ksxajT/jp3PS+DzQkQbTNiQEEYs= Received: from AM5PR1001CA0060.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:15::37) by DBBPR08MB4252.eurprd08.prod.outlook.com (2603:10a6:10:c2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24; Wed, 8 Jul 2020 12:13:50 +0000 Received: from AM5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:15::4) by AM5PR1001CA0060.outlook.office365.com (2603:10a6:206:15::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:13:50 +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 AM5EUR03FT008.mail.protection.outlook.com (10.152.16.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:13:50 +0000 Received: ("Tessian outbound e44de778b77e:v62"); Wed, 08 Jul 2020 12:13:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 52bbcd2e22a8a343 X-CR-MTA-TID: 64aa7808 Received: from cc2cc8e447f3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3F505574-D45F-4356-959C-C2EBEC685D18.1; Wed, 08 Jul 2020 12:13:44 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cc2cc8e447f3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:13:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KovOAVJeX7ijNY6acpUim0AkT6x8JUHKgGUsd/HvLZJU2MBhk7f8xieYfaHHgBlJfGvoTKrjIbiq79KqHEeiNzWZ20pxKJDeEvJeMQsZcW3miP+o8ANSkbwtyMA4G4opqD1TvzOSNhyfBwb90e3N+DFxEhm/pR/9Pb6+/x/a5ZMSYDgaUmZFFhGseNc3iNFUXY6+AcYdY7gEdBxJk3J9qHTgPgaQQtW3wvKjuViPCr4mHvsSLTaFGoOxlpZfawvccKyEUkQsz5ENmXbPRnDFGMOaoCW61mPPKVPTHuIzvOs7g3XVI5u/MpMIOscHQysoREhjxEcAGOYuj3/uLZKWig== 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=Ou0mr1ZYvIjpsVVHc+jlGLoVyKIaBhqKOr6JSzu27RA=; b=ThWh0ykyBEk4WnV3HskLoL2aAwF8SMgQKj5B3mmQY4ZKnOAJ41UB9ZnT0LqfEGCfz9pWVZILIFL8GuOz8hJDJdmxQ9rqJhZNOdlx5y4hZw3W2FxIoB6RllJbOt/aqaxhttVF+Wu9ZcZ8jSWw4773x+JDS+Wlcxav78UEMkx2DMHa5TK/TJYlXp1bswOjEqxy0oItKGq++FeayieTE59/YBpxyGAzPSNhT9KF55u3bKISPeTE53j6agLo1P7M9AOfDDLw9lWGnHBG3F7nsnEZKY8AD5ymp+RSm+Ecgq7hEaFufkQIfrSrZQHAepiRVEWCZ1Ei36fdxmmzpj5eWn37rQ== 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=Ou0mr1ZYvIjpsVVHc+jlGLoVyKIaBhqKOr6JSzu27RA=; b=x2t2oJJ7dBgb/CKABm0er3/g5LTuCYF9RevIL4lSsqa+NKtPcIefojjWCkwLkRv7unQ8zsvE3SGbykTq8ooSBV10YivnA7JlcnxKUG81kZKYlI/CAD4+NW+iRFq6hXL7SNdZID6jwpmadTF1ksxajT/jp3PS+DzQkQbTNiQEEYs= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:13:43 +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.3153.031; Wed, 8 Jul 2020 12:13:43 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 11/14] aarch64: Add pac-ret support to assembly files Date: Wed, 8 Jul 2020 13:13:37 +0100 Message-Id: <3439111b473697ec4f146bee1ace22759b8bad47.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P123CA0072.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::36) 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 LO2P123CA0072.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24 via Frontend Transport; Wed, 8 Jul 2020 12:13:43 +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: 03ace36f-6816-4c95-ebcb-08d823385f8f X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|DBBPR08MB4252: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 6aTuWjG3A0D8C0EpYV+btMmWW5whVvr9TH1Y/V5KnLqPFxiUANUthLAZoh+5wOOiJmsiYVcAV7UiEy78JR5UMx0pPgfFJckbf89fz9QUQ0jesN2NbsIvDWxZ0+73bONzeNhTNXLaj70TkzAI8S0V9t5KW0ajGBBpcmyy67FhvWa7iOSEA8lnajji2e5UXAI8Cq3q7RvwM9S4YCUk94LE+GHi/kmbR36KfkF4DPJ/U0KB8jDoN40IkMrWId+XV3DpYiGOUrtqA343lp/1PpZBjfRNfLwRJm2PM746q/mihfs3iUXnGp99nk5AXC3nbADaLKmSUnwAQjhf4sdYw6X/dh7OHkyXl3Fc/edCJC6wqDeK985xNOqqtNIC8JXGmd3ofesHteJVD+2dvPCnBAw9gw5pKi37Ca3TvcUpQsMqp68= 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jaP/onArge/y8UL17bvB0ycdLR3GhUXztSLSkqYuqdFFoqJtF9TyYIuyv/Ggo4iVznPRoM9VtfRwKlSbzv770g9V+ubQog6HWh1DfGszV3fFhIzfwkaAZFirISvRbx/D9vN1wypOvQiu/fkP9IW1j7tVwYlP70rhvsCel/MwamnPoS0WDsYlcVpxiza3xmfN820GQKjLj6h41JxMYyupMqAc5v2T6+vujlcfMQjfet24smP7zQDq59/T+i4x2rx0W3wLbxhCQJ1bmHhZXa41MZ9im5fj3Y6lrF5CK9/DWK1PCcqRGregzaXavtG4DGnYN9VCkS1CO2wiVUVRf+j+nA8igzWgSXmjJKRYkFGElI3RzhYmFNQHCjIe8JsNQJ9SJQ+Tiqw8vL1iy+Qh610qnxkQVNxNcMLEhhSJvI3WX8/vIyFQPwXI2pkSclffNWPGhYz1nNnldwGrmMINo/2+ihBI/XKcptSSzTmQ7TxWiJU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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: AM5EUR03FT008.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)(376002)(346002)(39860400002)(136003)(46966005)(356005)(2616005)(478600001)(336012)(316002)(81166007)(956004)(82310400002)(36906005)(8676002)(82740400003)(6486002)(69590400007)(70586007)(8936002)(70206006)(6506007)(6666004)(36756003)(47076004)(186003)(16526019)(26005)(5660300002)(86362001)(6512007)(2906002)(6916009)(44832011)(83380400001)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: c34e7aed-8133-490b-49de-08d823385b6d X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rQNBekVuRARihGFlpvSkdhS8NBAq5KESQaxdp60HaXWUw62dzBj/N43ypxlJAz146AaK6X+Xyw0pEa47G0S6yp3L0PEeXx5gFAaA4PMJzzSzjljWigrO2rMYlvWw5AagHUWGFzVufgrTPZpNrhvcpU85r0bvB8m30ivQmCa1wVjot9nfMSkU9hxe9COYmR1o+ZTBUxKZCWe2xU6ZMFAKOteej2o/hUx6uWXkum3g+KniPevqN8mDgeJYNtR90NdposIgZ3ps/tPluKMHGrKXexSLbH8rvKkGehyLjbvUwB0BS0ujQ+nKOBzWnvB3WkY6NJEou3wuxttj6QXfGw21x4xYSk3BHdEsE/lRA+QtwG5Chyh9dqReVU2U95S61n18Cb8KEYX0Z0oHGNgb29wwdH8I6B2vjC/UvywDS7s3KI3GJr1nKQGTIe4keu7jvDIv5kNDKN4DyriH2LPSAqfO+Q== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:13:50.0684 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03ace36f-6816-4c95-ebcb-08d823385f8f X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4252 X-Spam-Status: No, score=-16.0 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 0eeb0bb2f1..cd88023163 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 Wed Jul 8 12:13:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39976 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 B2BB838618F6; Wed, 8 Jul 2020 12:14:16 +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-eopbgr60085.outbound.protection.outlook.com [40.107.6.85]) by sourceware.org (Postfix) with ESMTPS id 01A803861872 for ; Wed, 8 Jul 2020 12:14:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 01A803861872 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=S4hGujQ0QLt/MzWi0JeNnCM+WTkka0iZlsCo+d1aEso=; b=LDzPuE7zf5sIsXXta2NKv45eddNLE0+GaJYKiD4Sfun7YLMg+CBKt7oNdJp2QKw3zwc9bhYaJjadTrdIb8Nsx5kwOxmIZQAiRk3z9rSWDJ+ogzx2ZTnCgwMz/mTlMaXanU+jetEVNjbXn1NuiXZAQWXdilo6AXHI46laeZiPnnk= Received: from AM7PR03CA0027.eurprd03.prod.outlook.com (2603:10a6:20b:130::37) by DB8PR08MB5482.eurprd08.prod.outlook.com (2603:10a6:10:116::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:14:12 +0000 Received: from VE1EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:130:cafe::55) by AM7PR03CA0027.outlook.office365.com (2603:10a6:20b:130::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:14:12 +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 VE1EUR03FT022.mail.protection.outlook.com (10.152.18.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:14:12 +0000 Received: ("Tessian outbound 2dd9eeca983c:v62"); Wed, 08 Jul 2020 12:14:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7b87f53c2a08b72a X-CR-MTA-TID: 64aa7808 Received: from fde60c2b094c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 71FE3973-0C5D-42C7-8E82-2B438DC4DD03.1; Wed, 08 Jul 2020 12:14:07 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fde60c2b094c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:14:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oe6S/Pz+DZ25ROR9qiuGvu8Iyx8+8+/mpqDKslAghWcmsxWm1tv/i/Lz6MM2nMBOJMDT1KBr7OD22f+wdC1XfslVKf654bSJp37Hs15SRNTHcO6KDJ32pTzt2ZryQOpkr42egjyrIeJHZZYo+MGjbK3aaUP6uslc5Ow5ML8x4dCdq8wmA6KvmBEdHcS6kQkVOB+FYGwaVx0vre8olWcXFzblTVc1xDl+FWjJHq7l++sPjMZUq3uMXSmyUg8P046eIto+q/YI4VqC2OLsO6AoREurDDUQVKoQ/4gW3Qxu2VyfXQlHsvCTnkvR0MQs405zk/GXC/TzVHVoiiDn1A9wNw== 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=S4hGujQ0QLt/MzWi0JeNnCM+WTkka0iZlsCo+d1aEso=; b=YI7Lee8zNJmbwZeorqcWJ5Nh6cE1ED0uOXMXeggHAWHhRzAJa59VwXNhNItmZKxcbcqKoYKgNC3WFR/MIIaJ8PQL4RHjUEsWDGQ7XEG8dm/BZNx3WFB4Bq9xcaUrxPSRf6MKjWHH+hFEpSBud7UNQk62xEaBuQ53xFmVA5NPJ9XWLOIjYMLMgSxov2VA9QiPEutp8pxbLpqfTE/mmF4w3EheBnqXx7WL/BNQQur6PTlPTJHRbnOUNo4vyZ8fUmIvcNu5Y7DkvA2bAoYdpNxBpB7q0bcpgYg8AwK2HsKfvMfB1PNfjjTbWsZYH9f5Qc+p465bDnGvZFYrTGkfpszKag== 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=S4hGujQ0QLt/MzWi0JeNnCM+WTkka0iZlsCo+d1aEso=; b=LDzPuE7zf5sIsXXta2NKv45eddNLE0+GaJYKiD4Sfun7YLMg+CBKt7oNdJp2QKw3zwc9bhYaJjadTrdIb8Nsx5kwOxmIZQAiRk3z9rSWDJ+ogzx2ZTnCgwMz/mTlMaXanU+jetEVNjbXn1NuiXZAQWXdilo6AXHI46laeZiPnnk= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:14:06 +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.3153.031; Wed, 8 Jul 2020 12:14:06 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 12/14] aarch64: fix pac-ret support in _mcount Date: Wed, 8 Jul 2020 13:13:55 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM6PR08CA0049.namprd08.prod.outlook.com (2603:10b6:5:1e0::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 DM6PR08CA0049.namprd08.prod.outlook.com (2603:10b6:5:1e0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:14:05 +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: 1af72184-eddb-477b-0050-08d823386cdd X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|DB8PR08MB5482: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: AuODUyqVZ/vhQkuZC97ME8XWP0SYW4kmNQGGfV6W0TXNWTrBZFc9Uz9qkxcNkLXnVnh8qG27Ipa16EH1Gjr/6yt8pEFeKmT5OKn+uGKCRUBAB+pJ9ZnF2CywTgzlRFTU5K+NDwg/lVZ/qB43CPR9yW7drWFI33qRoTLBA6dCpo3s0vWw4htwuMrOd4spcPjnjXVSvBwl2fKh07GFbxcnuIY9G5rfw+zwjPGSKgAZFHYv3JEX48HYvqb890T7qjy7vxI3ghHnMi0Q4ABYpfUO2kYkfxpsZ8TKK4oSmFqV9GZrtxl2MSLZMIPAtP1htRBVbr/PbyhY3wklGuLf4Z7BcnIYOM0OHfns2vp6W8VYtDx6AS/nDfKkdXy5Tggwaky44UrF1ya/FsFmfpJzD+nRS7Q49FNQGjofVeQkqrNXJ7c= 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: LHN6Gsu+l6LlJxnxkSf8Tprq+wP3UGvkRfjIxxmcvQ2farZg+Q4A09XJ4Evjf7Rwyg9FX8A5Fc4+D+FD3uiZUgdZ/nTgboZ0B1tbiwYKUa5Xp9kRAtYHLe+UhPUsarYJDMS1GfyBTIoHvCaitg/6Itt8NEbskKdZ28K7V5fn2uERFXix4OMf8zJ2lmB2wZVlgnv6ecUph2+RiJ/ahz3WCfvRfLz86SI1JuGlNRDpLz4Mgf6oCj1qeBoNEm6ogNc0/4tOFgTw06KU70H5aI2YxsGyJT5AlzSc0rbtdnT4+apimhOt0+USL+zd1o0Hf61bn/Z6/VagT7DLiH/O/Gd/WK6UIsAkENDv88FhofROIrA4S3THAFF+iFhnHohihUaDOQHhzEV9bpcDUBEAHCC4sDaCH3AYcgv1MKTQZWr9Jb3m+Cq7s9JEVHzUh5MX30tMHWxZDAyvil89NiqJmIX2cX4i0pI1z5li3N/LQxyVQ94= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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: VE1EUR03FT022.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)(136003)(346002)(376002)(46966005)(36906005)(70206006)(6512007)(70586007)(44832011)(5660300002)(186003)(956004)(2616005)(6486002)(36756003)(26005)(8936002)(16526019)(478600001)(69590400007)(6506007)(81166007)(6666004)(6916009)(8676002)(86362001)(47076004)(83380400001)(356005)(82310400002)(336012)(2906002)(82740400003)(316002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 240966b4-3f2f-4556-c489-08d8233868d9 X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G/OFICgCKtIhxCT7VNKLIJchgtUgwn3NUVnVi2eKboNFpXIM4tIizPfze23nHCGaoILhYpIzXdwsDnWc6JiMsuoReKSGdeAI2Sm+q1INY/sYOl+LFmb2FVmC5qOj1hqpcSXmWPb2zil4kSJxA0p8WzWJOVeAWCFHUcf+JaA+mZDn5WDTUMfhzPwuZv0/vFB0tpFq8z/WnLlrpDVPbqDHrXgFTTDiF1Ryiq9R+CdKNhFvFsSndHyBUL7beKHvrk79iPRzjxvmNsktaMRuip4UcIlrVPCltvJxVyn+1lErL2KaduJYl6+meQbcr1At+pE1a0YK44r7f9B9JmQ41ixtEJHeAyYIhEz06f1YYTRfEYiFbYx2H8XM4C1GdNzQIdpGBio/AFi13ZP4+tyEoBO8cYoZE3m66iXYga0MS2WCX+Pd5oiVGkXO4s2u0+hFs0HK8Wv1lSyxnenrlJOELX2aVw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:14:12.2999 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1af72184-eddb-477b-0050-08d823386cdd X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5482 X-Spam-Status: No, score=-16.0 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. Reviewed-by: Adhemerval Zanella --- 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 cd88023163..f442506952 100644 --- a/sysdeps/aarch64/sysdep.h +++ b/sysdeps/aarch64/sysdep.h @@ -35,6 +35,17 @@ #define PTR_SIZE (1< X-Patchwork-Id: 39977 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 C08523861830; Wed, 8 Jul 2020 12:14:44 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70047.outbound.protection.outlook.com [40.107.7.47]) by sourceware.org (Postfix) with ESMTPS id D739A38618E2 for ; Wed, 8 Jul 2020 12:14:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D739A38618E2 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=p7vK6HTF6ekpiAw1lmb6Lj8c9T3msxk26kKVyhm5yP0=; b=spFVgY0tiZtuj2ufSaS0SxB3zPqgT1yNpxTZtL0nmrq2CbiYImb6chj+iNoxt6Bwo/iYV1+ajQjPLmBbNcdUALrj29hdQFUd/dTMU/WgReiwMm2+9/v5hUtZztDQIyOKGDwjN2W+7eHWLcz95DDKVD6b0Fg3rVGanl/QSGQJrkc= Received: from AM5PR0701CA0023.eurprd07.prod.outlook.com (2603:10a6:203:51::33) by VI1PR08MB2637.eurprd08.prod.outlook.com (2603:10a6:802:21::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.29; Wed, 8 Jul 2020 12:14:37 +0000 Received: from AM5EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:51:cafe::33) by AM5PR0701CA0023.outlook.office365.com (2603:10a6:203:51::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.8 via Frontend Transport; Wed, 8 Jul 2020 12:14:36 +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 AM5EUR03FT058.mail.protection.outlook.com (10.152.17.48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:14:36 +0000 Received: ("Tessian outbound 2dd9eeca983c:v62"); Wed, 08 Jul 2020 12:14:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ffccfb9d403f919f X-CR-MTA-TID: 64aa7808 Received: from 3d93613c1e87.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 09748D1E-D419-4B19-BCF8-8FDC195AD7F5.1; Wed, 08 Jul 2020 12:14:30 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3d93613c1e87.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:14:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W3/zXHy6fbS+q0VCZhM9Jl2L08uY3Z55l18J4o+29TsXSqFGb1PYPffOJ7dNnALtDdRmN/H8KriKuKOFL4EVIz68v6duMI/WuTFFkB8zoNY198HSX5fNNpqb3l0HboPuuQipQcfV5TcuDzEEr4J/29BS2s7joDtF92OPRwi+zsMpl15zqbks1z2bQLW/zjMgK+71D+2P7SUPZSWss+u1Yn9HxG9vctIyqLPwsKMIBVEhxHoOMv0z0ee9Yug03SDVxMhNsYPMts4SrHvb2veQ6hjjW34eD6hxuBxCJTCyyE/Cud1gMuay+lQfhAXsMW6NMjGyDPFxSLHHt5RAzvLfAg== 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=p7vK6HTF6ekpiAw1lmb6Lj8c9T3msxk26kKVyhm5yP0=; b=a+JvRBSL3tG+bv7G7OqTMwYcgFIEBzm6DWnuoNAzQIqJ7LLTz0Whr/hXPEXLp1JmxR4vBZ9e7rMkrXBRKNAC3jAvewH3hXssyah3xUDQgKunR/HomQbT5BHdSjIRB1q6NnLHAOkBJhM0VvDKTQdMiCB8mjAIsTwdbsj62wsnXjadWRlJfqo2ygxCTPsmul1Ykxktli3y+Rc+s2EXUuK6JjvWmGeb9UM2D/lPrAWAKvoxmDmOLcUI9MwGbsAItmWy+DWtcoGT4fSdBLsk2GNBsE1chcbPjPCStTLtm1o3d2tfjd4LzW7QiRyLZuU61XE0o59w3Lgsj3DVFyitiY5vWg== 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=p7vK6HTF6ekpiAw1lmb6Lj8c9T3msxk26kKVyhm5yP0=; b=spFVgY0tiZtuj2ufSaS0SxB3zPqgT1yNpxTZtL0nmrq2CbiYImb6chj+iNoxt6Bwo/iYV1+ajQjPLmBbNcdUALrj29hdQFUd/dTMU/WgReiwMm2+9/v5hUtZztDQIyOKGDwjN2W+7eHWLcz95DDKVD6b0Fg3rVGanl/QSGQJrkc= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:14:29 +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.3153.031; Wed, 8 Jul 2020 12:14:29 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 13/14] aarch64: redefine RETURN_ADDRESS to strip PAC Date: Wed, 8 Jul 2020 13:14:18 +0100 Message-Id: <0119a5f4785e77d21df99968a751b1bb65af9a9b.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN6PR16CA0071.namprd16.prod.outlook.com (2603:10b6:805:ca::48) 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 SN6PR16CA0071.namprd16.prod.outlook.com (2603:10b6:805:ca::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:14:28 +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: df66386b-7f5a-4aa3-8daf-08d823387b09 X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|VI1PR08MB2637: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Eco/uLQaaMXElm66VOJeJhUB/TnrExLqYlDleuP9SCfS1eL1e95RdRxXmXNAgAmC0P3f7h8KdI42QdfkrZ4BTFGXp1dNAsSAfTfHdRsfcZsxqwYPpfWY1O7UQoxGM82haB+iioMeoLsjkuXoUEaIJ1tOc2vsFY/mXPQca9l4pFLcBTQ8PJFU4F/RHxkDKYPa+W5mXp5STYO3hJX3tl0FtjssVJjxwGMkMSLXgeB1hM1AHZefcjkLG3Acfb5if+qFYUlksxMeXM19k1iSqZaCoYOHIT0Oa5AWmjMcE+FHptHDxKk4pl+vzIr4a/SJPmB6eyE/XP4/2LcCn0Q5cclxT50cBu+9ggcpJwk1LBOixHUE216feNLSzmLxoXwRUAkwK+ESji34udQhILMtr7I9IEIkhLYmK5O3VDsEzm+Kf7Y= 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HHyMTtCoshMrsxXwMBdvud05OAKe1StgzxkbDMpFtkTMzKD5CDHKTnTlVFUXd1/AU2Y+VCkVunbXN5R/Ljbck3fOr8mKjkyohBk1zRzYoyCJTms360OAC6urXM4cDHAJaIqUcOAU2BbhO5hIHDV4NCvCRpe6hXeKUCe1SxiCQfW+He6bGC1C/kvJuyViMGewIGbSqJtyWbLPUuTCJsJD9xg/jc10Vyaa+QJL9tekmXXZA+lfH4/goHYULBNNRvC5PvJ3nt5VMp9JK3KVPtqNSx2pROIhWAQY9a9gqwipn3/2pEAzfmZ/OCKpYhiGjJFBsF1/PKjGWeksd7jRGh88eB9kDxjUZtdNVwUvJuZY5DZHhzmClTRFQM+/HjPI9ofjoRJx20fQ8tubKU6O89NxKmem5ot5MenBAywmmiKRVGOGzTM2pNyjVMR7kc4Kg3O+fpgesiP5ORh5shgZdJ8U92arQwUA0YZ6JMa5Kr1RdEo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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: AM5EUR03FT058.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)(376002)(346002)(136003)(39860400002)(46966005)(956004)(81166007)(336012)(5660300002)(69590400007)(8936002)(478600001)(316002)(6916009)(36906005)(47076004)(82740400003)(6506007)(70206006)(6666004)(44832011)(6486002)(2906002)(186003)(16526019)(83380400001)(26005)(2616005)(86362001)(36756003)(6512007)(70586007)(356005)(82310400002)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 20c7bb06-22be-4a4e-fda7-08d8233876f6 X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r0mywmTX0Ic9If4VhxyULEhWsWT6PelE/ultlshwcl4j9KlkkreL6XdpHqCJJekhh93Jv4A/4nNGDro1dr57ALNLZdKRdT/IoCvasRGHTy51/N9eGC8RDmJ/ZuP21PbIJegF5NNJXBAQRoQEy+nbQGZSMu3y4LUvHBwCYtDQql9bqwFJixemKhmYjW6+H3Fz+I+aiRBe7+MkycOhOmNceXznMglOkZpxh24mgPNk0u16n5mTHX3V4aZtKRPPd1RyhjaiMVCP6Y2DdkT4I42XVHutHpAn/v8mp59iEPGg2Ei0Dmf/4YvC3KOewB9rqGjFyUPtm59hWpg03yMN04S0FMzL4tHOz4oaWlXOaHAxOqzq89r3JYoYbYHnfr7k6WpOOn2PUl93YA29zuIIKH5GJXQQs62S4WMh5Jf/ZvxFWsF1kemhZovZZmyosiz96P3J6nYhEnSpKkLOn+Y1uOC3Hg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:14:36.1565 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df66386b-7f5a-4aa3-8daf-08d823387b09 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2637 X-Spam-Status: No, score=-16.0 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/94891: __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. Reviewed-by: Adhemerval Zanella --- sysdeps/aarch64/sysdep.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h index f442506952..ae269146e3 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/94891. */ +# if HAVE_AARCH64_PAC_RET +# undef RETURN_ADDRESS +# define RETURN_ADDRESS(n) strip_pac (__builtin_return_address (n)) +# endif #endif #ifdef __ASSEMBLER__ From patchwork Wed Jul 8 12:14:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39978 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 27B7338618FF; Wed, 8 Jul 2020 12:15:01 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20081.outbound.protection.outlook.com [40.107.2.81]) by sourceware.org (Postfix) with ESMTPS id 930953861843 for ; Wed, 8 Jul 2020 12:14:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 930953861843 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=E4xInZUS3InrnwaukwkcAhAbeCfvGs4aGkN56jP3PsY=; b=QYCpEQi8Bd5oJTbQh3rm4gOLH1vY0mvSE2GKPI3tZnN8lqbGQUZ8EYofnFJBT7J1EeOUoK71yJi76SepvICqz2wWx9H8Ukv1+ILWyPgT3UmrSNhJ1rlok5usHuZVh76ZJHr3KgWAcJcLIl8PqOtRC+mJWBw7+0ngewMRcBtuQtE= Received: from AM5PR0202CA0004.eurprd02.prod.outlook.com (2603:10a6:203:69::14) by VI1PR08MB2943.eurprd08.prod.outlook.com (2603:10a6:802:23::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20; Wed, 8 Jul 2020 12:14:55 +0000 Received: from VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:69:cafe::98) by AM5PR0202CA0004.outlook.office365.com (2603:10a6:203:69::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Wed, 8 Jul 2020 12:14:55 +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.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:14:55 +0000 Received: ("Tessian outbound b8ad5ab47c8c:v62"); Wed, 08 Jul 2020 12:14:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d6f5dece7d1ab600 X-CR-MTA-TID: 64aa7808 Received: from 82b932ec01b4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E5913145-C8C0-4EF0-9BA5-3317A7010FB5.1; Wed, 08 Jul 2020 12:14:49 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 82b932ec01b4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:14:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RTovpAuOjptw3qg6I1RrLlPLtbvyMAiDlRUYqsO248KiT7wvi8t7S+jL17kNsaUiIduHhiQZc7p4/cw177rkr+KZk9AC2d77lFFWNk7ognOa2+GE+UvBL0V7Q4WD72pk6/MwVCYUi/NvyYg6nFLwh0KMSlIIqlrpAuTOOlIHLE1VU4gNONkRBw2YUqnXWx/fDax//Bu5ZJzm7T+lUHQGEZ9KSrbaRNc/zineJw/Co4OUiFzVz7wP+huIeZldjI2A9NO/5QLuKMSmLtX5V3ZzlrB9OUI+AAuPYwM1bT8JRWqGPZtJdtkslLkMtmSkYKHhZCp2CJVUYGFONQFsdoa6WQ== 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=E4xInZUS3InrnwaukwkcAhAbeCfvGs4aGkN56jP3PsY=; b=M4sLn4Mm2ZN162pP2bOePnMSWSR1uAZ00QKMZMmK1xHaSrURymmNQ97fmnx54to36DlYyB/YfSAwwWZFpTNz3zF7bl9nBSOOzM+DPE9TF1Ik9HTHef2dce4gkZSx7QpuTwSZzZxlvfFSaWHQRL7f2SLf05ZrMBm1da/UfwOfAS4TSe8aSRsvOppZo1Zzw6p8fQWwP+StSRRr2CwreTew47d8dS7oNXUx8Kn1ojhiVuNu1oJu7+W6lp8WXIzOn4yjBjoCzNltIZLN6wX0+LBvhEs8pIL0BohQmLtbG1hWb3yW0BXEjdwEfRiBlzwi/kSDeAcJ/G3EQ2HwMmTUqU01Jw== 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=E4xInZUS3InrnwaukwkcAhAbeCfvGs4aGkN56jP3PsY=; b=QYCpEQi8Bd5oJTbQh3rm4gOLH1vY0mvSE2GKPI3tZnN8lqbGQUZ8EYofnFJBT7J1EeOUoK71yJi76SepvICqz2wWx9H8Ukv1+ILWyPgT3UmrSNhJ1rlok5usHuZVh76ZJHr3KgWAcJcLIl8PqOtRC+mJWBw7+0ngewMRcBtuQtE= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:14:48 +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.3153.031; Wed, 8 Jul 2020 12:14:48 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 14/14] aarch64: add NEWS entry about branch protection support Date: Wed, 8 Jul 2020 13:14:41 +0100 Message-Id: <90d6dfb05675c96e1f4cd35187d2fb783fc00204.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0138.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::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 LO2P265CA0138.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:14:47 +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: bb9366cd-bce6-490d-1a47-08d82338864c X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|VI1PR08MB2943: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: zlzLHXc0+xuHnJerVKzPhAlL4TFc1TFjti0ZU6X7H8QvA7Hw1g4w0g+feqGbG2/PvPuMgHHJB58XDPZvkrwSb4YEZvQPqD2k3AcQfU7voKRXPQK0jPGKBFKEtCU3B9O09zM6nZwMQL/hQZfhBahE3QCdJM4rcNnO0AD5C11+EKvvlu9PrE6xjcOTN21GgUiZy9giRhWlmol5Ad2ylULEe17TfWdQGsTrkJSfQHhQfJurrER3waDNmu3/wferUlLAQC1EnxTkJtUhov+RsHe+aut9r3ruEIHmjc8YPmAnzPJix1Zh0bMd2K2hXMgyYsPbHN0IB3uxIL7IlibormL+XV0JO0YVn/nr/tyVi98XhfBQ2/F+gFFe0JvdEBOIF6LLgjHX2wFzSMLK4eowJJkYj4YLz6bmlk7rW6onVcIUvLs= 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)(136003)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qJ0Oiyh2E0jafHLaqPkPVOqGgHmg/hwcDcxQUZHRs4H+8qI51+QyoqVI6J6c8gFMwjUvymK4sgc+Wh0MmmaYhnoFRQiPbpqn9btx3y8QMolTc/V27TBbOBSpAr0IRABF1tw9tEVQeSGz6isBPosKh5ulAaGYUDhXGoVdLxWumcDSLY29O6xAwDF7lFfViOE2wnhjD+KbPQIgQAhk+LC1JzQIEb7kX3VpsWIveYWmWueKLtEuyirwG7hHViFVcL6ylrzUJtxWH7a5Fx8+Rgwguikfj0lBVaEoq0zrb5YlqpBQWVMal95lC3KLXfMFKaBStIA2WAulJsd5CAV22bsfqOjDaFqWtwgZOKrnydCuVymyoijoy1FfTqaLsIAY4rm5Bukrzw1Z1LcceO2cwR6Ty/hagJViWEBQQVhCHpORVe06KvqyYR936t3HRBZY7aeRKdssQ+2Wj6Vso3q3RoNHX5Aozg9WBrATt6LEeHom6U4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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)(346002)(136003)(376002)(396003)(39860400002)(46966005)(186003)(16526019)(6512007)(2906002)(6506007)(8936002)(26005)(83380400001)(44832011)(8676002)(478600001)(36906005)(2616005)(956004)(6916009)(82740400003)(356005)(82310400002)(6486002)(336012)(81166007)(316002)(47076004)(70206006)(36756003)(5660300002)(6666004)(86362001)(70586007)(69590400007)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 332f5e72-9d5a-439c-6b3e-08d823388205 X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hUeqXHDiKCLj1yA7wpSn/pcBdp5v0hzlRDYDMR2jLC+HPM9CCf2XSwFjYjrgNfg0G1dYFZTMMJ03nWvqcxBueB01zd5hNNUrK9vg2CHOIO7cOgczrn/gGQtbS12rbNJh4AGUNEvElRx/Y9AviuChM9w5tRTDoWcVsG6rKr6C0ELK7xKreq95iI0Z+BJNtidrQdAARYJhUsLr5r/S2q1CqynpV0F5bfknAqlRODhLV4xxnPhLcpb60j5Y5iJek7cIcGfeP+RflWGaigqT2wjs1Pi1sK6cVLWKKxkRCy9eo5sy/TxDKO0bHmz6k2yTdaJ06/8GuEZw7nTv8mgkCoJZND8LLoLEcSmMBhrHqSWw556C1QezpBhJWGQgkcnEb90Lm1Wmn7z4jqoK08LkSc3BFjKrVAq2YqfWAtCRkU6tD7OANSkOMkcW4nCaolbXOtm8BMzieROwavM6DGFpW+Oo2Q== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:14:55.0070 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb9366cd-bce6-490d-1a47-08d82338864c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2943 X-Spam-Status: No, score=-16.0 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/NEWS b/NEWS index d7282b4ad5..5083f5eacf 100644 --- a/NEWS +++ b/NEWS @@ -67,6 +67,17 @@ Major new features: They should be used instead of sys_errlist and sys_nerr, both are thread and async-signal safe. These functions are GNU extensions. +* 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. + Deprecated and removed features, and other changes affecting compatibility: * The deprecated header and the sysctl function have been