From patchwork Mon Jun 22 14:01:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39729 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8923D388B00B; Mon, 22 Jun 2020 14:01:36 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80070.outbound.protection.outlook.com [40.107.8.70]) by sourceware.org (Postfix) with ESMTPS id 5AF6D388A82E for ; Mon, 22 Jun 2020 14:01:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5AF6D388A82E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OrWIdejFRvcSzaJ59gNmXkyaenI0h4cQ+xf+ZbXTUZQ=; b=t9L3DlopnRXhUgopBQt5H6XFJPWRkzl6MMmvd08XCgOh2427D/AtQm8oMKrLOfdkNu6xvse3us/DvhYu/OavgzRaciWIxpSC00bSSqFJoMU6GpjDxlVKrZFH2genUi/NC4q6ZRT42PWZpDRremrgqhQU/hi5unpcpUsE8bCp53A= Received: from DB6P192CA0002.EURP192.PROD.OUTLOOK.COM (2603:10a6:4:b8::12) by DB6PR0802MB2439.eurprd08.prod.outlook.com (2603:10a6:4:a0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.24; Mon, 22 Jun 2020 14:01:32 +0000 Received: from DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b8:cafe::d3) by DB6P192CA0002.outlook.office365.com (2603:10a6:4:b8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Mon, 22 Jun 2020 14:01:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT041.mail.protection.outlook.com (10.152.21.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:32 +0000 Received: ("Tessian outbound 147ff5d152c1:v59"); Mon, 22 Jun 2020 14:01:32 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6d07aa717a7ebbbf X-CR-MTA-TID: 64aa7808 Received: from 6b8e86a340a2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0BED76CC-6561-41EC-9AFB-53554F37E250.1; Mon, 22 Jun 2020 14:01:27 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6b8e86a340a2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:01:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P1qO5UCSdY7lujoSwGDiQLMKVAoTTRz8FeH9et6Rsoxa3IZlXDevrslBQkRe+QYUDDPm13dX031x6sEUs7k/k9YN15sAXoVxnEUwC4pqzzBxMxjYX1rvkylY/AKj1q9ZGkPS3kipkox5anzv587HtsWX/1KPa5wxGYFyxaXADKkdgN0ulPN6r+yJihzt/o8jBfYz07dW+7cy8YFvooBKZXESfm0S+DUGbDCYYz/V0r1GW76DLJrCIUUjkD7ymMRFLNlmaj7rPMyRBHMp79VGAHst/mLXx6NtK9p9yyNnMwVYbI6TKJfJdRCLvb1o34NufZ5R+CSdXKN+5Ae+qcTNQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OrWIdejFRvcSzaJ59gNmXkyaenI0h4cQ+xf+ZbXTUZQ=; b=hlj1Pa1rkxZOzvbDPaTBZ4xCHaxKTR63KuuF97WH/jI3PEpZp4AEcjGfJ8Rcy2/+1wkhdVpjBst6Mkjw8lGuPugxHDQrHeBx5sDg85/sHLWk6UQCmDmIjRpDTuZOfMfUxLmGOsehYFAxEeYZqMQUBPGnclqF9/1MxxLROx2mSNGHtL/ScAxtq+6nnwsOCrGI+trIskrrUKa4vCd5zudYhLsXSy3y4VHxJQKedN+E5YgjxSt2bPT9NuLx0CryfZfolYmbyjd0m9mt9moyTARrg2SE0AhZ+VpD66YeHE74SaEEwxfTKt5mFSzD1IXlT0RnUJJhjl89wMH8pkzP5ayD1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OrWIdejFRvcSzaJ59gNmXkyaenI0h4cQ+xf+ZbXTUZQ=; b=t9L3DlopnRXhUgopBQt5H6XFJPWRkzl6MMmvd08XCgOh2427D/AtQm8oMKrLOfdkNu6xvse3us/DvhYu/OavgzRaciWIxpSC00bSSqFJoMU6GpjDxlVKrZFH2genUi/NC4q6ZRT42PWZpDRremrgqhQU/hi5unpcpUsE8bCp53A= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB3640.eurprd08.prod.outlook.com (2603:10a6:20b:4c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:01:26 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 14:01:26 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 13/14] aarch64: redefine RETURN_ADDRESS to strip PAC Date: Mon, 22 Jun 2020 15:01:20 +0100 Message-Id: <6d42e5c2203cd7f8a9c0de04c12bb96fe09e260e.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0473.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::29) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LO2P265CA0473.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:25 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0b86f9bb-f443-4047-b2df-08d816b4c4ce X-MS-TrafficTypeDiagnostic: AM6PR08MB3640:|DB6PR0802MB2439: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: IMv+Mg7obEtsq/yjCrY1wBxhaZAcpcEs9+T3EaSwARbPdC1pqUJYQp7STOamEZeIR4+0QCdK2W6rvJxSnCqcbO4WqR9Mehb3LxlerfT2dngo6zbYJfK+yu7amFm29TSdwxy2BF/ThiYLN2dEjOrFMbIfCnhLNsz5JLh3BgDE+3kdl98MY0GZ2zVrvATgs15c+jjGMm93CAYM7lSEWo2M+YgJ0NpEf0pfSH7FOaguYnOLwDGVX2FJ2ez5YWEu3K/N8Ens4tRDpYiRadW/JeSo29JYuAHMEazymeQxd1D+BKpGZBIJDw/Nma3haHSi4CNP7Fns8ngkMwGS8twJcS3dD/yR4rghpMbNa4rKcEL7/ytEsMmY9IUwkQUJuAI/9sE49zPuZJd4j8fSQqGUxETDCIam2nL22xKmzHcrgv/GS9g= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(376002)(136003)(39860400002)(396003)(366004)(86362001)(44832011)(16526019)(478600001)(186003)(316002)(6506007)(52116002)(6916009)(26005)(2616005)(956004)(8936002)(6486002)(5660300002)(6512007)(83380400001)(66476007)(6666004)(36756003)(2906002)(8676002)(66946007)(66556008)(69590400007)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HwRyF6r0Me7T2vhgLrQaJxAhb01jqBMa7FLX6EXehzuoNgIAb4ozqb83KbAnr9TOTJ6S4XtjPwPFwFw+LbwqBdpVg22MrSyp97gkSDBfGzBwayH9NDW4S0Pc0zgao/pe9wfBGHYuFQyKh0BColnn5aL86Y+YNKPe57S3/VMfJR9hhYDWl9OBVijnWQQc1VF0sF6fak7vEc+sWASLDd374Xky9wf1eQ/LoDqpTdnW+ZnVW+l5nVcQGK6pzoX/jnnfx8fVCOQdSsgIS1ni24jtuFxaGqYGqd1HNVb7Jd16tnpJPTpNKc+PvndfI0q3uFcQv8O0lGBrMar+Y1IkuAMSdcj8TL2CQWSRB4Te7W/9Uk05K2Hur8o5noAtLpJc1r3ijK6Bx4T4EhJAbUuVbnjny1Han8+OLFVpLj4WUPRZqinzJBTCf31Q/orZCeuZPvYXEX999ZExrEECg5MJSj/vbqHw4LCFXNwgKPlvHCOkO68= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3640 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(346002)(376002)(39860400002)(136003)(396003)(46966005)(26005)(6486002)(5660300002)(6512007)(6916009)(47076004)(356005)(69590400007)(82740400003)(8936002)(82310400002)(83380400001)(86362001)(8676002)(81166007)(44832011)(2616005)(6506007)(336012)(956004)(316002)(70586007)(70206006)(2906002)(36756003)(478600001)(6666004)(186003)(16526019)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: ea2877db-4c40-490a-137b-08d816b4c0cd X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GYEWLJWTdqkChpZWgvtihCtDSYGWSehUKzv0i1pSBOUXwfRQHgOu3GKBsalhmevTgbiMBPUcro3BNs8+D7ryvVrZZkn86D1p1npktAvShrBCMTbtwFfc0IOGjOgfBBsuvjbjx6VwX1TDMbVzp6HNDWxFLWsD0Q0Q95+43qbNtargrigh/N0N0GMNbh3G5wx7eNcWg3Nd9YKJTLYlAE8qbHkuo4v0TdQ+n0B0WpoVvWGJm4okt46Jjdp2fqog+QePYTwUfYIdI0MoCotSpxHOaYWTXpX16CAPY/evN07+qgfmpjaYVqvBs3XXv9VFYmI13bQZ9l2suSu2OuH41wAfnW92CK1Gx+NaN5mqbZV7bFdOxfdxN82vCAg/Mtqfz0azzl2KI/rtsS4czJiZPWpBM8gADoaVlERiiUS1CNv+CxXq1VE2xpKmMtdAOK2sAijhTwprUfQOAnBak63BMEk1ow== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:01:32.4650 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b86f9bb-f443-4047-b2df-08d816b4c4ce X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2439 X-Spam-Status: No, score=-16.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" RETURN_ADDRESS is used at several places in glibc to mean a valid code address of the call site, but with pac-ret it may contain a pointer authentication code (PAC), so its definition is adjusted. This is gcc PR target/95891: __builtin_return_address should not expose signed pointers to user code where it can cause ABI issues. In glibc RETURN_ADDRESS is only changed if it is built with pac-ret. There is no detection for the specific gcc issue because it is hard to test and the additional xpac does not cause problems. --- sysdeps/aarch64/sysdep.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h index 2879aeaa5c..593bdd35a2 100644 --- a/sysdeps/aarch64/sysdep.h +++ b/sysdeps/aarch64/sysdep.h @@ -44,6 +44,13 @@ strip_pac (void *p) asm ("hint 7 // xpaclri" : "+r"(ra)); return ra; } + +/* This is needed when glibc is built with -mbranch-protection=pac-ret + with a gcc that is affected by PR target/95891. */ +# if HAVE_AARCH64_PAC_RET +# undef RETURN_ADDRESS +# define RETURN_ADDRESS(n) strip_pac (__builtin_return_address (n)) +# endif #endif #ifdef __ASSEMBLER__