From patchwork Thu Nov 19 05:20:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 41128 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 860CA398B40B; Thu, 19 Nov 2020 09:45:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 860CA398B40B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605779157; bh=ljFsrM5uleJ/lM6+U9ZGcbm05n1Mhu++Yg45Di0I3oI=; h=Resent-From:Resent-Date:Resent-To:Date:Subject:To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:Cc:From; b=NHyFlgXn9/O7nsPQdCaPtHrUGVTjnLgKoTZWuGG4pSGhsbnG3jMFxIYuCQMfDNw71 VmS+Eyul3FKYNeImKoxSmwhooXcNNQ1ipkEntR2IVQfxZfKF/KrJyriVPOkCv0rY/A +ctIkRpltOg/ywsbF/G3fnBJB8HpUgGXXRFF6InA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by sourceware.org (Postfix) with ESMTPS id A7931386F419 for ; Thu, 19 Nov 2020 09:45:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A7931386F419 Received: from gaia (unknown [2.26.170.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4EF9246BB for ; Thu, 19 Nov 2020 09:45:51 +0000 (UTC) Resent-From: Catalin Marinas Resent-Date: Thu, 19 Nov 2020 09:45:49 +0000 Resent-Message-ID: <20201119094549.GB4376@gaia> Resent-To: libc-alpha@sourceware.org Received: from DB6PR0801MB2022.eurprd08.prod.outlook.com (2603:10a6:4:76::15) by VI1PR0802MB2141.eurprd08.prod.outlook.com with HTTPS; Thu, 19 Nov 2020 05:20:43 +0000 Received: from DB9PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:10:1da::24) by DB6PR0801MB2022.eurprd08.prod.outlook.com (2603:10a6:4:76::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.28; Thu, 19 Nov 2020 05:20:39 +0000 Received: from DB5EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1da:cafe::6c) by DB9PR05CA0019.outlook.office365.com (2603:10a6:10:1da::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Thu, 19 Nov 2020 05:20:39 +0000 Received-SPF: Pass (protection.outlook.com: domain of flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) receiver=protection.outlook.com; client-ip=209.85.219.202; helo=mail-yb1-f202.google.com; Received: from 64aa7808-inbound-1.mta.getcheckrecipient.com (34.249.187.16) by DB5EUR03FT011.mail.protection.outlook.com (10.152.20.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Thu, 19 Nov 2020 05:20:39 +0000 Received: ("Tessian outbound 8568756127d5:v71"); Thu, 19 Nov 2020 05:20:39 +0000 Received: from mail-yb1-f202.google.com (209.85.219.202) by AM5EUR03FT014.mail.protection.outlook.com (10.152.16.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Thu, 19 Nov 2020 05:20:19 +0000 X-TS-Email-ID: 28f0cd4f-1967-4cbc-8b9b-df2b1c35293a Received: from ce2949236cdb.1 by 64aa7808-inbound-1.mta.getcheckrecipient.com id 0D38F982-29E0-48D3-8EAA-C0BF1213E2F6.1; Thu, 19 Nov 2020 05:20:21 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-inbound-1.mta.getcheckrecipient.com with ESMTPS id ce2949236cdb.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 19 Nov 2020 05:20:21 +0000 Received: from AM6PR10CA0069.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::46) by DB6PR0801MB2119.eurprd08.prod.outlook.com (2603:10a6:4:34::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.21; Thu, 19 Nov 2020 05:20:20 +0000 Received: from AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::46) by AM6PR10CA0069.outlook.office365.com (2603:10a6:209:80::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Thu, 19 Nov 2020 05:20:19 +0000 Authentication-Results-Original: spf=pass (sender IP is 209.85.219.202) smtp.mailfrom=flex--pcc.bounces.google.com; arm.com; dkim=pass (signature was verified) header.d=google.com;arm.com; dmarc=pass action=none header.from=google.com;compauth=pass reason=100 Received-SPF: Pass (protection.outlook.com: domain of flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) receiver=protection.outlook.com; client-ip=209.85.219.202; helo=mail-yb1-f202.google.com; Received: from mail-yb1-f202.google.com (209.85.219.202) by AM5EUR03FT014.mail.protection.outlook.com (10.152.16.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Thu, 19 Nov 2020 05:20:19 +0000 Received: by mail-yb1-f202.google.com with SMTP id h9so5725434ybj.10 for ; Wed, 18 Nov 2020 21:20:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=ljFsrM5uleJ/lM6+U9ZGcbm05n1Mhu++Yg45Di0I3oI=; b=bTUpp3+JfIdrLwAeU01oy6oMMs6qeeeeM0E7YE2ruw2Qkyu6136zKIGlIrhO+yPByo eReyMfsnby2QRrOUqzERmJON8/lJ5ZLrsFavclTtPDeIAScW421pMbjQfMROg5PfEUPV dfokJiZJQ7rI6mieASrI3UtLAEBkPHI04O+IQEe/GHH8KScgzClK8JKA5T6avtdfrS4W hKbtB3BEBgGiHFiQz4LU1RmqWIXIb66rHHsIto2H8/IjRNQDMOkkeVrZJNtj5RhsBPZG SbkU6cS7+FU1VQz7WS6CXVMESLbVoYaSqerI3OrGAuaAmNj7+K9I8XCQ0taitvGHRRGz O7qg== X-Gm-Message-State: AOAM532NafIAnmtVxZhAsycI7Ux0qcCDjS96CzRKGS6aKR1mOR4BZchI SVtews0U0tex7RDOS4CzKrOYCY4uAePLqj48nA1c5cp9r/SAogZWQopV1oxjttlguNOAZXOPcvP w5xGma0vj5ZviP2/HipE91OtP9hFebR88ARTzGbbsumE8SK19qSRL1J8= X-Google-Smtp-Source: ABdhPJydFsVO4N8vzyH4tuXWJWK8xBvKy5ytaUTVT2wg4+Ze4Gk7iJyExFvg9CLpQH8uHRfCoa+tu5E= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:0:7220:84ff:fe09:385a]) (user=pcc job=sendgmr) by 2002:a25:d7d8:: with SMTP id o207mr12403745ybg.274.1605763218633; Wed, 18 Nov 2020 21:20:18 -0800 (PST) Date: Wed, 18 Nov 2020 21:20:11 -0800 Message-Id: <20201119052011.3307433-1-pcc@google.com> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [PATCH v3] arm64: Introduce prctl(PR_PAC_{SET,GET}_ENABLED_KEYS) To: Catalin Marinas , Evgenii Stepanov , Kostya Serebryany , Vincenzo Frascino , Dave Martin X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7d0d49f-54b6-4857-1ccf-08d88c4ada8e X-MS-TrafficTypeDiagnostic: DB6PR0801MB2119:|DB6PR0801MB2022: X-MS-Exchange-AtpMessageProperties: SA x-checktessianinbound: true MS-Exchange-Organization-PhishThresholdLevel: 2 NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: =?utf-8?q?8p3PesOnzM2wN2XhVzsxW2?= =?utf-8?q?0sBYvLcILDQdxCKqv0Kl1H990dtEULoe07nb7SBjDBQNxXkjEhmRltGVyYNH80Ky8?= =?utf-8?q?xpxDEbMz72BNeQGXseL2q769dBP1RqQueWUGkyUF8siO+qh31FcqGxCrrP68e6CZh?= =?utf-8?q?GyAsWFowEZqqvOmTw8PqiJ7oGmn8p82G/yiUl9Q4T+n3WkTCff0AZRmiJL/zM4z9D?= =?utf-8?q?eFVzd0s6DPqtOTZZZZD9E74eLJFdXLVyRoO3hB2a4pHCFTGU3PZrOzKE2PyUqBZ5c?= =?utf-8?q?diQC9dfKalBPmb0GEc4dtG8asToufxW4HHXCDQVIb5Ko0FEzFLGYHWGxfmbQ7E3qK?= =?utf-8?q?0tR71nVNeEKrI6vPqxUaIhqk/JHHs0CGMq9GDhh7LiC0ktG+MqMzcoDfPVfDaAVBw?= =?utf-8?q?uPQ7d0MoS9x4lfDhD2j4IDtB4qlakyVdGUZibpKBzdwwshGho/wclNNvJPU63Fjn3?= =?utf-8?q?117Rqyofzvhn0lWSqkaablFzsUeSPdWnEZYHeygiWmSYiGjgyLceJ8NRtSnh8i52A?= =?utf-8?q?+7TdhiC2+HC//bCC6nXPIihB9AxK1Jr3VrI+r/IQNiWeM0eAlgOk15Q5PaPEV6hwp?= =?utf-8?q?xOkCZpIlSHX7W2QiESe/ONu+dG1tctxrO+QEOiLeWw4FChcCvWdrYwfoRuAHFZFj/?= =?utf-8?q?FNUYcI6VLFCbwJhha4ViAqBm2POqX1olGdST2f+YP7fCamvMNNhJGKq+BOFzW7xE3?= =?utf-8?q?53npfUjNY/kiyc7j3LSTCR8mjIgB0WetaFGH3EVfWyTZM4toNZD6FRdwvUP6SsYLV?= =?utf-8?q?+f+sCIR3Hy5vB/Mqj8PuDJZErgz/i7ROJi1R6D64hAI5sk0gBb7IgX5aag3p4izM1?= =?utf-8?q?fZgAp39bgGO3T1jf34cPLahbGIDdy1WCVXayoo21LAoqUe+m7pSCTqGbkMFskDbIc?= =?utf-8?q?EHDxBKXsZB04gGMiIX+aT4fJI/vYqigZeL8DLxZ8u3R0A5cLCa2CQfAzrGCURy4uz?= =?utf-8?q?360pFjaOpBDSh+ibsgFKY7otWUTE9DxacQtie0fQsSceNR1fBEtFJ52rgtKOV70tF?= =?utf-8?q?ziglt3ngYFZFhfAUidlXBjJzht5X6OdEOvZoJrshLJOiXMcfqLAUHAiyCnvlDruHP?= =?utf-8?q?h18BrhJjF3nyXSp258r12Offofrzc6UCg5C0IpmteWiM0D4vFksk5Gdf8k6cISVCH?= =?utf-8?q?itPYIa1cJ6sVnst76PGMc1mE8QKGRSj5UBGK7mSVLDPld9pN5BKVipXTtq0ORwt1b?= =?utf-8?q?KJJHF22dBgd6DO7Flr1ETiCsVFrBcgw01GLCakfzN2wtxEfQ1dqMGgUpeNMHLf5EV?= =?utf-8?q?NTXBjvO42j1jwALB1qKncfPyvtKE9ezgjUKqcG5hiBScUXsGI2u2dHTINFfKOXqL1?= =?utf-8?q?XYCBPfY/wIXKeOf92Imycak5NK1q7efC4izBTbHNZh8h53DnkVCrPGwu6VbbEFWs?= =?utf-8?q?=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:209.85.219.202; CTRY:US; LANG:en; SCL:-1; SRV:; IPV:NLI; SFV:SKN; H:mail-yb1-f202.google.com; PTR:mail-yb1-f202.google.com; CAT:NONE; SFS:; DIR:INB; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2119 X-OrganizationHeadersPreserved: DB6PR0801MB2119.eurprd08.prod.outlook.com Original-Authentication-Results: spf=pass (sender IP is 209.85.219.202) smtp.mailfrom=flex--pcc.bounces.google.com; arm.com; dkim=pass (signature was verified) header.d=google.com;arm.com; dmarc=pass action=none header.from=google.com;compauth=pass reason=100 X-MS-Exchange-Organization-ExpirationStartTime: 19 Nov 2020 05:20:39.5140 (UTC) X-MS-Exchange-Organization-ExpirationStartTimeReason: OriginalSubmit X-MS-Exchange-Organization-ExpirationInterval: 1:00:00:00.0000000 X-MS-Exchange-Organization-ExpirationIntervalReason: OriginalSubmit X-MS-Exchange-Organization-Network-Message-Id: c7d0d49f-54b6-4857-1ccf-08d88c4ada8e X-MS-Exchange-Organization-MessageDirectionality: Originating X-MS-Exchange-SkipListedInternetSender: ip=[209.85.219.202]; domain=mail-yb1-f202.google.com X-MS-Exchange-ExternalOriginalInternetSender: ip=[209.85.219.202]; domain=mail-yb1-f202.google.com X-MS-Exchange-Organization-SCL: -1 X-CrossPremisesHeadersPromoted: DB5EUR03FT011.eop-EUR03.prod.protection.outlook.com X-CrossPremisesHeadersFiltered: DB5EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-Organization-AuthSource: AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-Organization-AuthAs: Anonymous X-OriginatorOrg: arm.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7a4a51c4-6cb7-4b77-6143-08d88c4acee4 X-Microsoft-Antispam: BCL:0; X-Forefront-Antispam-Report: CIP:34.249.187.16; CTRY:US; LANG:en; SCL:-1; SRV:; IPV:NLI; SFV:SKN; H:mail-yb1-f202.google.com; PTR:mail-yb1-f202.google.com; CAT:NONE; SFS:; DIR:INB; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2020 05:20:39.5070 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7d0d49f-54b6-4857-1ccf-08d88c4ada8e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[34.249.187.16]; Helo=[64aa7808-inbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2022 X-MS-Exchange-Transport-EndToEndLatency: 00:00:03.5036850 X-MS-Exchange-Processed-By-BccFoldering: 15.20.3589.022 X-Microsoft-Antispam-Mailbox-Delivery: ucf:1; jmr:0; auth:0; dest:C; OFR:CustomRules; ENG:(750128)(520002050)(944506458)(944626604); X-Microsoft-Antispam-Message-Info: =?utf-8?q?eOjEwnF3LE/r3Clvbc2Tgb0h4NlSyQF?= =?utf-8?q?fsSnBL/tTyrTDbChWJTDdsfyP+BjXlVtWQ1ydvOFHAHmFg6FbPNj3IOCLJm7wZw80?= =?utf-8?q?4/b75MSZ8+3GnRMPr+3DkI4R6Y5COuZaw0stJG+vkxuz37oguefUB6YaD0FVWQlyn?= =?utf-8?q?R6bbUCRKh+Ysa23PTv9hi3Eoddvn0BoWbCvVRqJlpZPNoxOynzsD1QbWHul86aBBS?= =?utf-8?q?sggdtIVl1yNBu65frw+1SNhDu/kbOfOi9xsb+D3Sy+IK9vP6CVLdvPouFkD8tW+97?= =?utf-8?q?q4QKazihXQNIDWQS4g6RILE2LSiX9l8lTB8KgEupIoGVbk8+xy5UVPROm6wYovFEo?= =?utf-8?q?qmv74F0b2BVX5zMr35RKs33th9xcwGx541NjYzUxLxbRoVm307PCgUwEvpLtXks0Z?= =?utf-8?q?LBdP2+mveQtklfcQkxMv+hwc915mCRRqFniGdyYzP0vI0m+/dmML1DTqdplbzqsw4?= =?utf-8?q?DcZKAuxXaujlstdnPaUSMFmgF71eeRTTpp1Uw1FXBWZDEfgT0hlBde5CJLrAtpCwb?= =?utf-8?q?LOojPbqsxJ+jfXOubRFf79HA/QEhpr2kIIJSaP4tNtGWbRzTqCoDUaFLoZmU07BfC?= =?utf-8?q?bRoO6m5+kNQRo4+csKTaKJjlQNGndFSCLZRFk/u3doZ64ZeGXDd5qit9fGsdvzq+6?= =?utf-8?q?XcmVLgPgVuvS6WjmHVa/KNRkQil1nZ+S71BzqMWAA3BBeuJP231yXLV5fp2WjCYcV?= =?utf-8?q?t1ioU/C7UOdiS0V0N5h17QJh4notecuct1hHBmRjiFZW+FYShMM0TvGbYB3erZK/c?= =?utf-8?q?sprKahakKIo1Rf6+MzvsdtgQPXUr2MGkFxVaXnS4ZgyeL9tbJTQ26GhtIXhWnD9dz?= =?utf-8?q?uNTBuh4U8uHyHUAnxzgYCEvSNVBFqFEZBhY8PmhEufwNbPmKPLwoj9pGDYG8RyXZn?= =?utf-8?q?FpxkDp1BH8buQ5sYAV6ey+t3bIEHhw7NElPZCNdTzyl+dYUVH3egsL7P/HBSisFrl?= =?utf-8?q?ngvSuKOeArTjShWIdljvGAw0kVDJT7IRpJmbUI4m9DqIj3EckcO3xVWktwc4XLLVl?= =?utf-8?q?w32VXiuSy12ffIQLT7UJBxwElRW1jWVq53hmx4n2blKycEMvDS6jgH8uF7B/x80pj?= =?utf-8?q?o0Dsuo6ZFVbWS6na1wZC3X+OdWH/zGCFn/ZaiIZ9/udxhq1HBD/0BSxKbSQzfYSBq?= =?utf-8?q?tZ3p2Qh99tZ5C7ch5m5gXvnn4tZGKaUsiGnUCQ1pBoAB07jDrw1clpTbiqGyaejm1?= =?utf-8?q?3ElUrJnAklaakfQqocKV88D/bg9fHgzEKWdU2WHxJFktdj6LdFmmiBJM8z1r50ahb?= =?utf-8?q?tGF9KKSp3ZizSWh1IJ5Hl9xLHnUm+lZ2mT5JUvGKF8dbCdpp6p0pAoiaHi2JJ6ggk?= =?utf-8?q?KbB0/EZ3nvtXUFxGQdtWE01IWLUXuGoL40QuS51YPaCmmBSNF34seLfmSOyWzqHql?= =?utf-8?q?9FeX7uQ0rHcwnmepH+FtoAmPT41ASP0ZVJi00JCIGwr6qiE0OUu41lOtess+qVZHa?= =?utf-8?q?vFC0uEx/Sj4wuXsewNbLlopG2uQYqnj19bKggiTMnZ0331EQScE6AgDbp5ak/ZMcq?= =?utf-8?q?iSldDAtvh?= MIME-Version: 1.0 X-Spam-Status: No, score=-18.2 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, SPF_HELO_NONE, SPF_PASS, TXREP, UNPARSEABLE_RELAY, USER_IN_DEF_DKIM_WL 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: , X-Patchwork-Original-From: Peter Collingbourne via Libc-alpha From: Peter Collingbourne Reply-To: Peter Collingbourne Cc: Peter Collingbourne , Andrey Konovalov , Kevin Brodsky , linux-api@vger.kernel.org, Will Deacon , Linux ARM Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This prctl allows the user program to control which PAC keys are enabled in a particular task. The main reason why this is useful is to enable a userspace ABI that uses PAC to sign and authenticate function pointers and other pointers exposed outside of the function, while still allowing binaries conforming to the ABI to interoperate with legacy binaries that do not sign or authenticate pointers. The idea is that a dynamic loader or early startup code would issue this prctl very early after establishing that a process may load legacy binaries, but before executing any PAC instructions. Signed-off-by: Peter Collingbourne Link: https://linux-review.googlesource.com/id/Ibc41a5e6a76b275efbaa126b31119dc197b927a5 Reviewed-by: Dave Martin --- v3: - fix some style nits - move kernel entry ISB to after setting EnIA - rename sctlr -> sctlr_user - remove init_sctlr v2: - added prctl(PR_PAC_GET_ENABLED_KEYS) - added ptrace APIs for getting and setting the set of enabled keys - optimized the instruction sequence for kernel entry/exit - rebased on top of MTE series .../arm64/pointer-authentication.rst | 27 +++++++++ arch/arm64/include/asm/mte.h | 4 +- arch/arm64/include/asm/pointer_auth.h | 26 ++++++++- arch/arm64/include/asm/processor.h | 19 ++++++- arch/arm64/include/asm/sysreg.h | 4 +- arch/arm64/kernel/asm-offsets.c | 1 + arch/arm64/kernel/entry.S | 30 +++++++++- arch/arm64/kernel/mte.c | 42 ++++---------- arch/arm64/kernel/pointer_auth.c | 55 +++++++++++++++++++ arch/arm64/kernel/process.c | 39 ++++++++++++- arch/arm64/kernel/ptrace.c | 41 ++++++++++++++ include/uapi/linux/elf.h | 1 + include/uapi/linux/prctl.h | 4 ++ kernel/sys.c | 16 ++++++ 14 files changed, 267 insertions(+), 42 deletions(-) diff --git a/Documentation/arm64/pointer-authentication.rst b/Documentation/arm64/pointer-authentication.rst index 30b2ab06526b..1f7e064deeb3 100644 --- a/Documentation/arm64/pointer-authentication.rst +++ b/Documentation/arm64/pointer-authentication.rst @@ -107,3 +107,30 @@ filter out the Pointer Authentication system key registers from KVM_GET/SET_REG_* ioctls and mask those features from cpufeature ID register. Any attempt to use the Pointer Authentication instructions will result in an UNDEFINED exception being injected into the guest. + + +Enabling and disabling keys +--------------------------- + +The prctl PR_PAC_SET_ENABLED_KEYS allows the user program to control which +PAC keys are enabled in a particular task. It takes two arguments, the +first being a bitmask of PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY +and PR_PAC_APDBKEY specifying which keys shall be affected by this prctl, +and the second being a bitmask of the same bits specifying whether the key +should be enabled or disabled. For example:: + + prctl(PR_PAC_SET_ENABLED_KEYS, + PR_PAC_APIAKEY | PR_PAC_APIBKEY | PR_PAC_APDAKEY | PR_PAC_APDBKEY, + PR_PAC_APIBKEY, 0, 0); + +disables all keys except the IB key. + +The main reason why this is useful is to enable a userspace ABI that uses PAC +instructions to sign and authenticate function pointers and other pointers +exposed outside of the function, while still allowing binaries conforming to +the ABI to interoperate with legacy binaries that do not sign or authenticate +pointers. + +The idea is that a dynamic loader or early startup code would issue this +prctl very early after establishing that a process may load legacy binaries, +but before executing any PAC instructions. diff --git a/arch/arm64/include/asm/mte.h b/arch/arm64/include/asm/mte.h index 1c99fcadb58c..adbb05ece04c 100644 --- a/arch/arm64/include/asm/mte.h +++ b/arch/arm64/include/asm/mte.h @@ -37,7 +37,7 @@ void mte_free_tag_storage(char *storage); void mte_sync_tags(pte_t *ptep, pte_t pte); void mte_copy_page_tags(void *kto, const void *kfrom); -void flush_mte_state(void); +void mte_thread_init_user(void); void mte_thread_switch(struct task_struct *next); void mte_suspend_exit(void); long set_mte_ctrl(struct task_struct *task, unsigned long arg); @@ -56,7 +56,7 @@ static inline void mte_sync_tags(pte_t *ptep, pte_t pte) static inline void mte_copy_page_tags(void *kto, const void *kfrom) { } -static inline void flush_mte_state(void) +static inline void mte_thread_init_user(void) { } static inline void mte_thread_switch(struct task_struct *next) diff --git a/arch/arm64/include/asm/pointer_auth.h b/arch/arm64/include/asm/pointer_auth.h index c6b4f0603024..8346f6e60736 100644 --- a/arch/arm64/include/asm/pointer_auth.h +++ b/arch/arm64/include/asm/pointer_auth.h @@ -3,6 +3,7 @@ #define __ASM_POINTER_AUTH_H #include +#include #include #include @@ -71,13 +72,27 @@ static __always_inline void ptrauth_keys_switch_kernel(struct ptrauth_keys_kerne extern int ptrauth_prctl_reset_keys(struct task_struct *tsk, unsigned long arg); +extern int ptrauth_prctl_set_enabled_keys(struct task_struct *tsk, + unsigned long keys, + unsigned long enabled); +extern int ptrauth_prctl_get_enabled_keys(struct task_struct *tsk); + static inline unsigned long ptrauth_strip_insn_pac(unsigned long ptr) { return ptrauth_clear_pac(ptr); } -#define ptrauth_thread_init_user(tsk) \ - ptrauth_keys_init_user(&(tsk)->thread.keys_user) +#define ptrauth_thread_init_user() \ + do { \ + ptrauth_keys_init_user(¤t->thread.keys_user); \ + \ + /* enable all keys */ \ + if (system_supports_address_auth()) \ + set_task_sctlr_el1(current->thread.sctlr_user | \ + SCTLR_ELx_ENIA | SCTLR_ELx_ENIB | \ + SCTLR_ELx_ENDA | SCTLR_ELx_ENDB); \ + } while (0) + #define ptrauth_thread_init_kernel(tsk) \ ptrauth_keys_init_kernel(&(tsk)->thread.keys_kernel) #define ptrauth_thread_switch_kernel(tsk) \ @@ -85,10 +100,15 @@ static inline unsigned long ptrauth_strip_insn_pac(unsigned long ptr) #else /* CONFIG_ARM64_PTR_AUTH */ #define ptrauth_prctl_reset_keys(tsk, arg) (-EINVAL) +#define ptrauth_prctl_set_enabled_keys(tsk, keys, enabled) (-EINVAL) +#define ptrauth_prctl_get_enabled_keys(tsk) (-EINVAL) #define ptrauth_strip_insn_pac(lr) (lr) -#define ptrauth_thread_init_user(tsk) +#define ptrauth_thread_init_user() #define ptrauth_thread_init_kernel(tsk) #define ptrauth_thread_switch_kernel(tsk) #endif /* CONFIG_ARM64_PTR_AUTH */ +#define PR_PAC_ENABLED_KEYS_MASK \ + (PR_PAC_APIAKEY | PR_PAC_APIBKEY | PR_PAC_APDAKEY | PR_PAC_APDBKEY) + #endif /* __ASM_POINTER_AUTH_H */ diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index fce8cbecd6bc..f430dd2fb61a 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -153,11 +153,15 @@ struct thread_struct { struct ptrauth_keys_kernel keys_kernel; #endif #ifdef CONFIG_ARM64_MTE - u64 sctlr_tcf0; u64 gcr_user_incl; #endif + u64 sctlr_user; }; +#define SCTLR_USER_MASK \ + (SCTLR_ELx_ENIA | SCTLR_ELx_ENIB | SCTLR_ELx_ENDA | SCTLR_ELx_ENDB | \ + SCTLR_EL1_TCF0_MASK) + static inline void arch_thread_struct_whitelist(unsigned long *offset, unsigned long *size) { @@ -249,6 +253,14 @@ extern void release_thread(struct task_struct *); unsigned long get_wchan(struct task_struct *p); +#if defined(CONFIG_ARM64_PTR_AUTH) || defined(CONFIG_ARM64_MTE) +void set_task_sctlr_el1(u64 sctlr); +#else +static inline void set_task_sctlr_el1(u64 sctlr) +{ +} +#endif + /* Thread switching */ extern struct task_struct *cpu_switch_to(struct task_struct *prev, struct task_struct *next); @@ -303,6 +315,11 @@ extern void __init minsigstksz_setup(void); /* PR_PAC_RESET_KEYS prctl */ #define PAC_RESET_KEYS(tsk, arg) ptrauth_prctl_reset_keys(tsk, arg) +/* PR_PAC_{SET,GET}_ENABLED_KEYS prctl */ +#define PAC_SET_ENABLED_KEYS(tsk, keys, enabled) \ + ptrauth_prctl_set_enabled_keys(tsk, keys, enabled) +#define PAC_GET_ENABLED_KEYS(tsk) ptrauth_prctl_get_enabled_keys(tsk) + #ifdef CONFIG_ARM64_TAGGED_ADDR_ABI /* PR_{SET,GET}_TAGGED_ADDR_CTRL prctl */ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg); diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index e2ef4c2edf06..96e3337ca7b3 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -554,8 +554,10 @@ #define SCTLR_ELx_TCF_ASYNC (UL(0x2) << SCTLR_ELx_TCF_SHIFT) #define SCTLR_ELx_TCF_MASK (UL(0x3) << SCTLR_ELx_TCF_SHIFT) +#define SCTLR_ELx_ENIA_SHIFT 31 + #define SCTLR_ELx_ITFSB (BIT(37)) -#define SCTLR_ELx_ENIA (BIT(31)) +#define SCTLR_ELx_ENIA (BIT(SCTLR_ELx_ENIA_SHIFT)) #define SCTLR_ELx_ENIB (BIT(30)) #define SCTLR_ELx_ENDA (BIT(27)) #define SCTLR_ELx_EE (BIT(25)) diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 7d32fc959b1a..062d3e37edb5 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -48,6 +48,7 @@ int main(void) DEFINE(THREAD_KEYS_USER, offsetof(struct task_struct, thread.keys_user)); DEFINE(THREAD_KEYS_KERNEL, offsetof(struct task_struct, thread.keys_kernel)); #endif + DEFINE(THREAD_SCTLR_USER, offsetof(struct task_struct, thread.sctlr_user)); BLANK(); DEFINE(S_X0, offsetof(struct pt_regs, regs[0])); DEFINE(S_X2, offsetof(struct pt_regs, regs[2])); diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index b295fb912b12..c8c1a284a76a 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -210,7 +210,20 @@ alternative_else_nop_endif check_mte_async_tcf x19, x22 apply_ssbd 1, x22, x23 - ptrauth_keys_install_kernel tsk, x20, x22, x23 + ptrauth_keys_install_kernel_nosync tsk, x20, x22, x23 + +#ifdef CONFIG_ARM64_PTR_AUTH +alternative_if ARM64_HAS_ADDRESS_AUTH + /* Enable IA for in-kernel PAC if the task had it disabled. */ + ldr x0, [tsk, THREAD_SCTLR_USER] + tbnz x0, SCTLR_ELx_ENIA_SHIFT, 1f + mrs x0, sctlr_el1 + orr x0, x0, SCTLR_ELx_ENIA + msr sctlr_el1, x0 +1: + isb +alternative_else_nop_endif +#endif scs_load tsk, x20 .else @@ -330,6 +343,21 @@ alternative_else_nop_endif /* No kernel C function calls after this as user keys are set. */ ptrauth_keys_install_user tsk, x0, x1, x2 +#ifdef CONFIG_ARM64_PTR_AUTH +alternative_if ARM64_HAS_ADDRESS_AUTH + /* + * IA was enabled for in-kernel PAC. Disable it now if needed. + * All other per-task SCTLR bits were updated on task switch. + */ + ldr x0, [tsk, THREAD_SCTLR_USER] + tbnz x0, SCTLR_ELx_ENIA_SHIFT, 1f + mrs x0, sctlr_el1 + bic x0, x0, SCTLR_ELx_ENIA + msr sctlr_el1, x0 +1: +alternative_else_nop_endif +#endif + apply_ssbd 0, x0, x1 .endif diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c index 52a0638ed967..16040a1e0fd1 100644 --- a/arch/arm64/kernel/mte.c +++ b/arch/arm64/kernel/mte.c @@ -72,26 +72,6 @@ int memcmp_pages(struct page *page1, struct page *page2) return ret; } -static void update_sctlr_el1_tcf0(u64 tcf0) -{ - /* ISB required for the kernel uaccess routines */ - sysreg_clear_set(sctlr_el1, SCTLR_EL1_TCF0_MASK, tcf0); - isb(); -} - -static void set_sctlr_el1_tcf0(u64 tcf0) -{ - /* - * mte_thread_switch() checks current->thread.sctlr_tcf0 as an - * optimisation. Disable preemption so that it does not see - * the variable update before the SCTLR_EL1.TCF0 one. - */ - preempt_disable(); - current->thread.sctlr_tcf0 = tcf0; - update_sctlr_el1_tcf0(tcf0); - preempt_enable(); -} - static void update_gcr_el1_excl(u64 incl) { u64 excl = ~incl & SYS_GCR_EL1_EXCL_MASK; @@ -111,7 +91,7 @@ static void set_gcr_el1_excl(u64 incl) update_gcr_el1_excl(incl); } -void flush_mte_state(void) +void mte_thread_init_user(void) { if (!system_supports_mte()) return; @@ -121,7 +101,8 @@ void flush_mte_state(void) write_sysreg_s(0, SYS_TFSRE0_EL1); clear_thread_flag(TIF_MTE_ASYNC_FAULT); /* disable tag checking */ - set_sctlr_el1_tcf0(SCTLR_EL1_TCF0_NONE); + set_task_sctlr_el1((current->thread.sctlr_user & ~SCTLR_EL1_TCF0_MASK) | + SCTLR_EL1_TCF0_NONE); /* reset tag generation mask */ set_gcr_el1_excl(0); } @@ -131,9 +112,6 @@ void mte_thread_switch(struct task_struct *next) if (!system_supports_mte()) return; - /* avoid expensive SCTLR_EL1 accesses if no change */ - if (current->thread.sctlr_tcf0 != next->thread.sctlr_tcf0) - update_sctlr_el1_tcf0(next->thread.sctlr_tcf0); update_gcr_el1_excl(next->thread.gcr_user_incl); } @@ -147,7 +125,7 @@ void mte_suspend_exit(void) long set_mte_ctrl(struct task_struct *task, unsigned long arg) { - u64 tcf0; + u64 sctlr = task->thread.sctlr_user & ~SCTLR_EL1_TCF0_MASK; u64 gcr_incl = (arg & PR_MTE_TAG_MASK) >> PR_MTE_TAG_SHIFT; if (!system_supports_mte()) @@ -155,23 +133,23 @@ long set_mte_ctrl(struct task_struct *task, unsigned long arg) switch (arg & PR_MTE_TCF_MASK) { case PR_MTE_TCF_NONE: - tcf0 = SCTLR_EL1_TCF0_NONE; + sctlr |= SCTLR_EL1_TCF0_NONE; break; case PR_MTE_TCF_SYNC: - tcf0 = SCTLR_EL1_TCF0_SYNC; + sctlr |= SCTLR_EL1_TCF0_SYNC; break; case PR_MTE_TCF_ASYNC: - tcf0 = SCTLR_EL1_TCF0_ASYNC; + sctlr |= SCTLR_EL1_TCF0_ASYNC; break; default: return -EINVAL; } if (task != current) { - task->thread.sctlr_tcf0 = tcf0; + task->thread.sctlr_user = sctlr; task->thread.gcr_user_incl = gcr_incl; } else { - set_sctlr_el1_tcf0(tcf0); + set_task_sctlr_el1(sctlr); set_gcr_el1_excl(gcr_incl); } @@ -187,7 +165,7 @@ long get_mte_ctrl(struct task_struct *task) ret = task->thread.gcr_user_incl << PR_MTE_TAG_SHIFT; - switch (task->thread.sctlr_tcf0) { + switch (task->thread.sctlr_user & SCTLR_EL1_TCF0_MASK) { case SCTLR_EL1_TCF0_NONE: return PR_MTE_TCF_NONE; case SCTLR_EL1_TCF0_SYNC: diff --git a/arch/arm64/kernel/pointer_auth.c b/arch/arm64/kernel/pointer_auth.c index adb955fd9bdd..025f38dff464 100644 --- a/arch/arm64/kernel/pointer_auth.c +++ b/arch/arm64/kernel/pointer_auth.c @@ -46,3 +46,58 @@ int ptrauth_prctl_reset_keys(struct task_struct *tsk, unsigned long arg) return 0; } + +static u64 arg_to_enxx_mask(unsigned long arg) +{ + u64 sctlr_enxx_mask = 0; + + if (arg & PR_PAC_APIAKEY) + sctlr_enxx_mask |= SCTLR_ELx_ENIA; + if (arg & PR_PAC_APIBKEY) + sctlr_enxx_mask |= SCTLR_ELx_ENIB; + if (arg & PR_PAC_APDAKEY) + sctlr_enxx_mask |= SCTLR_ELx_ENDA; + if (arg & PR_PAC_APDBKEY) + sctlr_enxx_mask |= SCTLR_ELx_ENDB; + return sctlr_enxx_mask; +} + +int ptrauth_prctl_set_enabled_keys(struct task_struct *tsk, unsigned long keys, + unsigned long enabled) +{ + u64 sctlr = tsk->thread.sctlr_user; + + if (!system_supports_address_auth() || is_compat_task()) + return -EINVAL; + + if ((keys & ~PR_PAC_ENABLED_KEYS_MASK) || (enabled & ~keys)) + return -EINVAL; + + sctlr &= ~arg_to_enxx_mask(keys); + sctlr |= arg_to_enxx_mask(enabled); + if (tsk == current) + set_task_sctlr_el1(sctlr); + else + tsk->thread.sctlr_user = sctlr; + + return 0; +} + +int ptrauth_prctl_get_enabled_keys(struct task_struct *tsk) +{ + int retval = 0; + + if (!system_supports_address_auth() || is_compat_task()) + return -EINVAL; + + if (tsk->thread.sctlr_user & SCTLR_ELx_ENIA) + retval |= PR_PAC_APIAKEY; + if (tsk->thread.sctlr_user & SCTLR_ELx_ENIB) + retval |= PR_PAC_APIBKEY; + if (tsk->thread.sctlr_user & SCTLR_ELx_ENDA) + retval |= PR_PAC_APDAKEY; + if (tsk->thread.sctlr_user & SCTLR_ELx_ENDB) + retval |= PR_PAC_APDBKEY; + + return retval; +} diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index a47a40ec6ad9..aa8bf0294c5d 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -339,7 +339,6 @@ void flush_thread(void) tls_thread_flush(); flush_ptrace_hw_breakpoint(current); flush_tagged_addr_state(); - flush_mte_state(); } void release_thread(struct task_struct *dead_task) @@ -541,6 +540,37 @@ static void erratum_1418040_thread_switch(struct task_struct *prev, write_sysreg(val, cntkctl_el1); } +#if defined(CONFIG_ARM64_PTR_AUTH) || defined(CONFIG_ARM64_MTE) +static void update_sctlr_el1(u64 sctlr) +{ + /* + * EnIA must not be cleared while in the kernel as this is necessary for + * in-kernel PAC. It will be cleared on kernel exit if needed. + */ + sysreg_clear_set(sctlr_el1, SCTLR_USER_MASK & ~SCTLR_ELx_ENIA, sctlr); + + /* ISB required for the kernel uaccess routines when setting TCF0. */ + isb(); +} + +void set_task_sctlr_el1(u64 sctlr) +{ + /* + * __switch_to() checks current->thread.sctlr as an + * optimisation. Disable preemption so that it does not see + * the variable update before the SCTLR_EL1 one. + */ + preempt_disable(); + current->thread.sctlr_user = sctlr; + update_sctlr_el1(sctlr); + preempt_enable(); +} +#else +static void update_sctlr_el1(u64 sctlr) +{ +} +#endif /* defined(CONFIG_ARM64_PTR_AUTH) || defined(CONFIG_ARM64_MTE) */ + /* * Thread switching. */ @@ -566,6 +596,10 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev, */ dsb(ish); + /* avoid expensive SCTLR_EL1 accesses if no change */ + if (prev->thread.sctlr_user != next->thread.sctlr_user) + update_sctlr_el1(next->thread.sctlr_user); + /* * MTE thread switching must happen after the DSB above to ensure that * any asynchronous tag check faults have been logged in the TFSR*_EL1 @@ -621,7 +655,8 @@ void arch_setup_new_exec(void) { current->mm->context.flags = is_compat_task() ? MMCF_AARCH32 : 0; - ptrauth_thread_init_user(current); + ptrauth_thread_init_user(); + mte_thread_init_user(); if (task_spec_ssb_noexec(current)) { arch_prctl_spec_ctrl_set(current, PR_SPEC_STORE_BYPASS, diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index f49b349e16a3..2ed17fb07666 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -911,6 +911,38 @@ static int pac_mask_get(struct task_struct *target, return membuf_write(&to, &uregs, sizeof(uregs)); } +static int pac_enabled_keys_get(struct task_struct *target, + const struct user_regset *regset, + struct membuf to) +{ + long enabled_keys = ptrauth_prctl_get_enabled_keys(target); + + if (IS_ERR_VALUE(enabled_keys)) + return enabled_keys; + + return membuf_write(&to, &enabled_keys, sizeof(enabled_keys)); +} + +static int pac_enabled_keys_set(struct task_struct *target, + const struct user_regset *regset, + unsigned int pos, unsigned int count, + const void *kbuf, const void __user *ubuf) +{ + int ret; + long enabled_keys = ptrauth_prctl_get_enabled_keys(target); + + if (IS_ERR_VALUE(enabled_keys)) + return enabled_keys; + + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &enabled_keys, 0, -1); + if (ret) + return ret; + + return ptrauth_prctl_set_enabled_keys(target, PR_PAC_ENABLED_KEYS_MASK, + enabled_keys); +} + #ifdef CONFIG_CHECKPOINT_RESTORE static __uint128_t pac_key_to_user(const struct ptrauth_key *key) { @@ -1076,6 +1108,7 @@ enum aarch64_regset { #endif #ifdef CONFIG_ARM64_PTR_AUTH REGSET_PAC_MASK, + REGSET_PAC_ENABLED_KEYS, #ifdef CONFIG_CHECKPOINT_RESTORE REGSET_PACA_KEYS, REGSET_PACG_KEYS, @@ -1162,6 +1195,14 @@ static const struct user_regset aarch64_regsets[] = { .regset_get = pac_mask_get, /* this cannot be set dynamically */ }, + [REGSET_PAC_ENABLED_KEYS] = { + .core_note_type = NT_ARM_PAC_ENABLED_KEYS, + .n = 1, + .size = sizeof(long), + .align = sizeof(long), + .regset_get = pac_enabled_keys_get, + .set = pac_enabled_keys_set, + }, #ifdef CONFIG_CHECKPOINT_RESTORE [REGSET_PACA_KEYS] = { .core_note_type = NT_ARM_PACA_KEYS, diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index 30f68b42eeb5..61bf4774b8f2 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -426,6 +426,7 @@ typedef struct elf64_shdr { #define NT_ARM_PACA_KEYS 0x407 /* ARM pointer authentication address keys */ #define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication generic key */ #define NT_ARM_TAGGED_ADDR_CTRL 0x409 /* arm64 tagged address control (prctl()) */ +#define NT_ARM_PAC_ENABLED_KEYS 0x40a /* arm64 ptr auth enabled keys (prctl()) */ #define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */ #define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note */ #define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */ diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index 7f0827705c9a..0d1bb3a2e59a 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -247,4 +247,8 @@ struct prctl_mm_map { #define PR_SET_IO_FLUSHER 57 #define PR_GET_IO_FLUSHER 58 +/* Set/get enabled arm64 pointer authentication keys */ +#define PR_PAC_SET_ENABLED_KEYS 59 +#define PR_PAC_GET_ENABLED_KEYS 60 + #endif /* _LINUX_PRCTL_H */ diff --git a/kernel/sys.c b/kernel/sys.c index a730c03ee607..b7f2878f053b 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -119,6 +119,12 @@ #ifndef PAC_RESET_KEYS # define PAC_RESET_KEYS(a, b) (-EINVAL) #endif +#ifndef PAC_SET_ENABLED_KEYS +# define PAC_SET_ENABLED_KEYS(a, b, c) (-EINVAL) +#endif +#ifndef PAC_GET_ENABLED_KEYS +# define PAC_GET_ENABLED_KEYS(a) (-EINVAL) +#endif #ifndef SET_TAGGED_ADDR_CTRL # define SET_TAGGED_ADDR_CTRL(a) (-EINVAL) #endif @@ -2497,6 +2503,16 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, return -EINVAL; error = PAC_RESET_KEYS(me, arg2); break; + case PR_PAC_SET_ENABLED_KEYS: + if (arg4 || arg5) + return -EINVAL; + error = PAC_SET_ENABLED_KEYS(me, arg2, arg3); + break; + case PR_PAC_GET_ENABLED_KEYS: + if (arg2 || arg3 || arg4 || arg5) + return -EINVAL; + error = PAC_GET_ENABLED_KEYS(me); + break; case PR_SET_TAGGED_ADDR_CTRL: if (arg3 || arg4 || arg5) return -EINVAL;