From patchwork Wed Jul 8 12:14:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 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__