From patchwork Mon Apr 12 09:04:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raoul Strackx X-Patchwork-Id: 12197215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF453C433B4 for ; Mon, 12 Apr 2021 09:06:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C57F0613AE for ; Mon, 12 Apr 2021 09:06:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238696AbhDLJGq (ORCPT ); Mon, 12 Apr 2021 05:06:46 -0400 Received: from mail-dm6nam12on2125.outbound.protection.outlook.com ([40.107.243.125]:21408 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240142AbhDLJFA (ORCPT ); Mon, 12 Apr 2021 05:05:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DsrG9CgZEgtLMhfspBfiPumfuXSle4uhoZy5pRMaIy+XiuGD8wRlCHjm/VS3lkvRDkFp+piSdMIHz/bb4Z8UO5quEqkcKyvp6Fn0rkzfhnQh18z+s8AiR/OeBYzTZEusgmUVjd3LzhYKNF0mxmNOo5Ak8K7qQAq6nJWVxBPnHWjhEwtfulhQWI/Cbzvlyr5VJ6tiirj+4/MBnOluIF3RZlaKz9P1wdf+8XPz1MkqEd9h9OPEzoTFtkjg9vQbwRdGgIQr3NJBhxMzIJ6ylGKDy/y1sePULsntG4PjcqLCVR3Rw6RHI/NZxgsTKzsalw/1qpdbO58KT1BQzoTjVgrBrA== 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=fc8Kck0rI90sPNfPmxxpUXA58/NsgLxjYBmzfGOsevI=; b=X5u/Q74AlxjvPxMvmMSoDk4zl63Ejg4M049kb4o0m7oYcjWNQymtMr6b1q4t2DCbyVo0TgwKGfO/nVND8CPd62f0pfcf236BbUnZKOffKcHfPjEYU9qwAhlgs5nlWNQnO7NMyUvCNrRBJQ6rUBPsr/+Gw/h6NgUVK5c+siT38jWrpnDZ8s0fhXyyO3PVplPOYQA7yDQZL/w5jHzduIKYU811L5YBvQ0u/Y7xsawLuwlkNh//6R6WFKKPapVYyGrxEJlLLnSyMRVmtgYXpP3rAKhMJAp8rTlrIUGw59iJwKPTn3lg9/mjPJRwmB+vjfjaM7A4P3GW3pGn97tHd71pMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fortanix.com; dmarc=pass action=none header.from=fortanix.com; dkim=pass header.d=fortanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fortanix.onmicrosoft.com; s=selector2-fortanix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fc8Kck0rI90sPNfPmxxpUXA58/NsgLxjYBmzfGOsevI=; b=Izj3WrK3lQkMI+/RoDtEjbTHBxJix/FBj33BsMeM+vBjDfkv3TuGgDbZNehlub0+QXxN9kaNRWzlGolz7Fg7a1Zenic1tWUW1deVXs8rtZKQgr7oporaN5uMYcY6RZRw7hUwNCH1dTeeieV4Gl/SyMqe9ZIJifEvBActT6dgHsI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=fortanix.com; Received: from CY4PR11MB1783.namprd11.prod.outlook.com (2603:10b6:903:11d::20) by CY4PR11MB1384.namprd11.prod.outlook.com (2603:10b6:903:2c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Mon, 12 Apr 2021 09:04:41 +0000 Received: from CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::f052:14fe:c2a9:5fb1]) by CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::f052:14fe:c2a9:5fb1%3]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 09:04:41 +0000 From: Raoul Strackx Subject: [PATCH v2 1/3] x86/sgx: Adding eextend ioctl To: Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org References: Autocrypt: addr=raoul.strackx@fortanix.com; keydata= LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgptUUlOQkYyb2lmOEJFQURN UkFMT1ZjRkYyTlQva1FsWTBtVnN3YlMrYi9WNzR1azZFcDdxenpoNHpHbEtSS1pzClplS0I4 WmpFT2h5Q2pZaExwdnJHTVh2cTV1bm5pWENIbG9BR1hZRm9rN0Q0SGd2Q0djYnlTYVRMQjds NHc4MFIKOStYUkp2SnJpMEdPSmVubjRnNUpIQU5RN2h5YWl5RlRIYTVERU5CMjc2VG9kZUFQ bnVidGl1VmRDT0lnQVJVbAp1dzJHemFsbmY0WmZ1TGdEaHg5YzIza2pjZTFBQkFWbWdxUEtN TkVUSnhyZFdLQUt5QkVIWGJ0Snh6YnR4bFI1CnFUZU8yTExCU2V4TFBDbTRZOTZzRHlGK3JJ a2FpRk5JQWk2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0SWNBY3lod05uY2lqYnNIUkFTQlJidkg5RFhJ c2wKaEwxMDArdzZNTWNMeFpNVmJ4UHBTWWVHaGp4SjdNUysyeGp3eDB4MWlMNmszZk5UNHNT Q3dZa0xRZjJlKzhxYwpFYjNTa0Q0VFR3RDQxUW85SFNuUlkwdnRqblNyZkwyQ3JhVmptOXhh MXhmNlJDQ3kvaXpKNU5TQTZZMXduT0U3Ck1IOHorcVFUM1NxMld0a0NzU1M5K1U2VU9OWmFK dFN5MWNvZ1ZhMDV1QWdRY0tHT3FvcHg3QWlmZUhIUFpqZnIKakVNaHJZQ3Q5WXgzR1VET0hs MnRObDJIOStqZC9BVjByMDRKUTNxSHRWM1Z5UTNxN0N1UTlCTTdnQzVpK1JleQpHSU14Zm0v a09GWTRLRUxOeVYrV01PK2lXRHpZS21tTUxnUkVXNitqZk5jMzhrYWhaQjI2RmJOZTh6QmxU cVpPCmhxYmNZR1ZZNW9Ec004YSthbkwyZDhmaStnPT0KPW9ZT0QKLS0tLS1FTkQgUEdQIFBV QkxJQyBLRVkgQkxPQ0stLS0tLQo= Message-ID: <67471818-fe87-32a9-ae9e-26a21ebd37e4@fortanix.com> Date: Mon, 12 Apr 2021 11:04:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Language: en-US X-Originating-IP: [81.164.43.210] X-ClientProxiedBy: AM0PR10CA0057.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::37) To CY4PR11MB1783.namprd11.prod.outlook.com (2603:10b6:903:11d::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (81.164.43.210) by AM0PR10CA0057.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Mon, 12 Apr 2021 09:04:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a48bbbfa-6622-416e-e440-08d8fd9201d2 X-MS-TrafficTypeDiagnostic: CY4PR11MB1384: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:248; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d567Lp/2nVNeNeSiwaodXrzhIHFUU1xjs00nMayB1kkxlqWB5C+w56f3qK+QdqrkDUBVUmNl7Ejv14PxltB58XEF3krY73eSsrWpBwWh4B9e3Xu0l8YryWzstR59oxGwhydBA96TZ8KpSJrYOesavEkB48LDh/ujlQNrm7e8idVkru2UwRlAVFyNrneBq4TOcZmBOPHF0ow7gPsVdiTgYdQkJjLXw4beU2uV4qRZXYmDU75Wd/G6roIc/aNjrAVvZKze6KesDWekUk4IO+9Ybs3nRrlvm9qRckRrwx1M7ihXRURYMVvzTyRtEnca2K6FSCbpt2wtjLhoA3Pe8vETCvQidvP/V9otnldtSjXuiPNHWXQWVG86wh+rNxvJcPwq4WdrIlDQk1jy+3sdYZXhEJLV2+Jmn3sfSop4dO54nc3MCqd8P0OMFFx5x5lB3kro+AK/NrTY3o2+PSDeKagNelxu4CUH3xESLRilhxIZ3egZ2Pb4cOeK0GcSSVVOqlqx990mYzZkzUpBuEBcTFpEf6B8zkHWC3tAFc5tT9U8sCGrNZ9dX5p98QShPvw/OJ3KM7m1CTvW8ghw5sk2WEtSG3UuHremTsDBhJNkCQfpk7QxzilDVcCly33VSIYlQR/SGKbY0BTdPOzvYBGhkMTb3o3n1W0sco2+TePdcD5reEWS+TlLN5qO5O980oxsDkHN2kJzb50FVo/M/rd/VIg0C9mM6Al6cLCJn/hAXyj/XVE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1783.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(39830400003)(376002)(136003)(396003)(366004)(26005)(66476007)(6486002)(186003)(16526019)(66556008)(44832011)(5660300002)(2616005)(38350700002)(316002)(86362001)(6666004)(956004)(66946007)(52116002)(31686004)(8936002)(8676002)(110136005)(36756003)(16576012)(2906002)(83380400001)(478600001)(38100700002)(31696002)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?bwi16hUqpijciZ9TnDoX5kSQuRdIdA?= =?utf-8?q?IRZKiFkJOyy2fOZ90qK0GUliDLbVMhPDNjH8oUBYoN9agzA8ETK2dGYPb35TXkCJi?= =?utf-8?q?R6i+MEFnjwSGk3UENWuvfenwlVpb4Pv4RyXSmVt+Owk2C+dN3ORJLG2hJZcb3CvdG?= =?utf-8?q?6of9JPjWhyQYLS8EzO9+ScR8iaAR6htgEGPbNiShzLNf1o903cjNBqW3CyObW5A1c?= =?utf-8?q?ft78M9rDdjxDjL9S5yI9xDqnvKcy8Y6aQf/rJftBPmCEOR8ogCWq2lAPvoo3CBfAP?= =?utf-8?q?ZA1o4ifPUEMwufSA9jXnjcEVrRb1mDLgU14F7VCWw8wTS1cdytXdg2ixIgtkeTt6p?= =?utf-8?q?nwTSgnflSK6S7T1URnM4/dkqfKAz44nnNZ2R+2bKw4cuUdmWQ8Qonje754j39nqQs?= =?utf-8?q?71ngMuk+91zn9OZVf0iAr07fCyunBCVy5jqivTVArJVhEXhfCU4A+LtmtRQsX1nbs?= =?utf-8?q?ZKltti5yca4kwxMlNMYsT5udnrE4NX54CMgcap/soXfYWaOwLB+F6JftEHgs597q7?= =?utf-8?q?GgPlWL9nm2qOXEqd+LRc29djsfa+/SmCMpA0bZo9DzF7byRCYyXBjgUSW12sERLCO?= =?utf-8?q?L47oPNjigtvwfXwqGG5IIjMyeCldWxl+1zwxxh+dQjwri1oksCELrKz41VCiHZudi?= =?utf-8?q?cDuC7Hnx34TyiGDNNWMvi8fFESDOvQ4t1YaGzbT7gkFuRZjdBc6S/+sjyX0m/mmsr?= =?utf-8?q?X2XPP6el0+S7v0isSNGg575Mzqx8+bSPwdLlUxGe0BeFaGTu1TTwjzWzrdSHVelWP?= =?utf-8?q?4b0aVNmDu582ox3IPaHit5Oaljt4dR/yhP9/ve1BxmeonucbX98vOxLORbysA/9tK?= =?utf-8?q?6S1SojXmzI1MmvVM9kMIVL4PtqBvML9yBd0eAcaQkRetGlJakU7pV9ROHKsjYh12q?= =?utf-8?q?EBAZg5DQRG1jjywrHogBAoT4cU5QeAyfsaJLKA0y/hfwanTLZ8YAv6N7vrkIPWD2S?= =?utf-8?q?lojHAAg/K2765sykX/F2KvgulcI0jxI2g7QUkKtI8BK1wwo74/aycvBH99V/i3BJl?= =?utf-8?q?obE4j120hKXdSWsLXwU1maAncEa3D607X6p+n9zRHBFrPMNTGEqGzkv48rwND0E9R?= =?utf-8?q?IP7/0qYhL0V+GSdZK2cu/H6aBF+b2yDGGi0zr4W3UFPfC6TotONskWLyc8dDwBhQf?= =?utf-8?q?l9cMb+Rx2rDS2ND/BgCx21DU5QbM+K/2zCrpor/pzbi+4vzWLNtZHROMKNAXpK3RS?= =?utf-8?q?Vhb9OipkfzEkdzyEhLpUrLJG4YpGsIC/EUdZ+1TBQqUDYjcm7XqAlHkuSzvx/GgT9?= =?utf-8?q?DvBqHrus+UZTob?= X-OriginatorOrg: fortanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: a48bbbfa-6622-416e-e440-08d8fd9201d2 X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1783.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 09:04:41.2844 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: de7becae-4883-43e8-82c7-7dbdbb988ae6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0LqDf0WIXnGLkM06rTrMaRDECPCCIbZYKpp20cFBWYqICgxGzlIICGj6g6pUwd1IlucZCqt+As37KOLa2riz54xz6c9s+mUT4045PCi4tic= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1384 Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org SGXv1 enclaves can be created by an ECREATE, followed by any number of EADD and EEXTEND functions. It is finalized by an EINIT. The SGX enclave vendor defines the order of these invocations when the enclave is being developed, and cannot be changed later on. Currently enclave measurements can only be extended per 4K measurements immediately after the page has been added by the EADD instruction. This commit adds a new ioctl to execute the EEXTEND leaf function per 256 bytes of enclave memory. In combination with the SGX_IOC_ENCLAVE_ADD_PAGES ioctl (without the SGX_PAGE_MEASURE flag), this enables the driver to load all SGXv1 compatible enclaves. Signed-off-by: Raoul Strackx --- arch/x86/include/uapi/asm/sgx.h | 11 ++++++ arch/x86/kernel/cpu/sgx/ioctl.c | 81 +++++++++++++++++++++++++++++++++++------ 2 files changed, 81 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/uapi/asm/sgx.h b/arch/x86/include/uapi/asm/sgx.h index 9034f30..121ca5f 100644 --- a/arch/x86/include/uapi/asm/sgx.h +++ b/arch/x86/include/uapi/asm/sgx.h @@ -27,6 +27,8 @@ enum sgx_page_flags { _IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init) #define SGX_IOC_ENCLAVE_PROVISION \ _IOW(SGX_MAGIC, 0x03, struct sgx_enclave_provision) +#define SGX_IOC_ENCLAVE_EXTEND \ + _IOW(SGX_MAGIC, 0x04, struct sgx_enclave_extend) /** * struct sgx_enclave_create - parameter structure for the @@ -57,6 +59,15 @@ struct sgx_enclave_add_pages { }; /** + * struct sgx_enclave_extend - parameter structure for the + * %SGX_IOC_ENCLAVE_MEASURE ioctl + * @offset: offset of the data from the start address for the data + */ +struct sgx_enclave_extend { + __u64 offset; +}; + +/** * struct sgx_enclave_init - parameter structure for the * %SGX_IOC_ENCLAVE_INIT ioctl * @sigstruct: address for the SIGSTRUCT data diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c index 90a5caf..69521e9 100644 --- a/arch/x86/kernel/cpu/sgx/ioctl.c +++ b/arch/x86/kernel/cpu/sgx/ioctl.c @@ -261,20 +261,20 @@ static int __sgx_encl_add_page(struct sgx_encl *encl, return ret ? -EIO : 0; } -/* - * If the caller requires measurement of the page as a proof for the content, - * use EEXTEND to add a measurement for 256 bytes of the page. Repeat this - * operation until the entire page is measured." - */ -static int __sgx_encl_extend(struct sgx_encl *encl, - struct sgx_epc_page *epc_page) +static int __sgx_encl_extend_chunk(struct sgx_encl *encl, + void *chunk, unsigned long size) { unsigned long offset; int ret; + void *secs_addr; - for (offset = 0; offset < PAGE_SIZE; offset += SGX_EEXTEND_BLOCK_SIZE) { - ret = __eextend(sgx_get_epc_virt_addr(encl->secs.epc_page), - sgx_get_epc_virt_addr(epc_page) + offset); + if (!size || !IS_ALIGNED(size, SGX_EEXTEND_BLOCK_SIZE)) + return -EINVAL; + + secs_addr = sgx_get_epc_virt_addr(encl->secs.epc_page); + for (offset = 0; offset < size; offset += SGX_EEXTEND_BLOCK_SIZE) { + ret = __eextend(secs_addr, + chunk + offset); if (ret) { if (encls_failed(ret)) ENCLS_WARN(ret, "EEXTEND"); @@ -286,6 +286,19 @@ static int __sgx_encl_extend(struct sgx_encl *encl, return 0; } +/* + * If the caller requires measurement of the page as a proof for the content, + * use EEXTEND to add a measurement for 256 bytes of the page. Repeat this + * operation until the entire page is measured." + */ +static int __sgx_encl_extend_page(struct sgx_encl *encl, + struct sgx_epc_page *epc_page) +{ + void *chunk = sgx_get_epc_virt_addr(epc_page); + + return __sgx_encl_extend_chunk(encl, chunk, PAGE_SIZE); +} + static int sgx_encl_add_page(struct sgx_encl *encl, unsigned long src, unsigned long offset, struct sgx_secinfo *secinfo, unsigned long flags) @@ -346,7 +359,7 @@ static int sgx_encl_add_page(struct sgx_encl *encl, unsigned long src, encl->secs_child_cnt++; if (flags & SGX_PAGE_MEASURE) { - ret = __sgx_encl_extend(encl, epc_page); + ret = __sgx_encl_extend_page(encl, epc_page); if (ret) goto err_out; } @@ -466,6 +479,49 @@ static long sgx_ioc_enclave_add_pages(struct sgx_encl *encl, void __user *arg) return ret; } +static long sgx_ioc_enclave_extend(struct sgx_encl *encl, void __user *user_arg) +{ + struct sgx_enclave_extend arg; + struct sgx_encl_page *encl_page; + void *chunk; + long ret = 0; + + if (!test_bit(SGX_ENCL_CREATED, &encl->flags) || + test_bit(SGX_ENCL_INITIALIZED, &encl->flags)) + return -EINVAL; + + if (copy_from_user(&arg, user_arg, sizeof(arg))) + return -EFAULT; + + if (!arg.offset || !IS_ALIGNED(arg.offset, SGX_EEXTEND_BLOCK_SIZE)) { + pr_info("offset not a multiple of 256: %llu\n", arg.offset); + return -EINVAL; + } + + encl_page = xa_load(&encl->page_array, PFN_DOWN(encl->base + arg.offset)); + + if (!encl_page) { + pr_info("enc page not found\n"); + return -EFAULT; + } + + mmap_read_lock(current->mm); + mutex_lock(&encl->lock); + sgx_unmark_page_reclaimable(encl_page->epc_page); + + chunk = sgx_get_epc_virt_addr(encl_page->epc_page) + (arg.offset & (PAGE_SIZE - 1)); + + if (__sgx_encl_extend_chunk(encl, chunk, SGX_EEXTEND_BLOCK_SIZE)) { + pr_info("extend returned an error\n"); + ret = -EFAULT; + } + + sgx_mark_page_reclaimable(encl_page->epc_page); + mutex_unlock(&encl->lock); + mmap_read_unlock(current->mm); + return ret; +} + static int __sgx_get_key_hash(struct crypto_shash *tfm, const void *modulus, void *hash) { @@ -706,6 +762,9 @@ long sgx_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) case SGX_IOC_ENCLAVE_PROVISION: ret = sgx_ioc_enclave_provision(encl, (void __user *)arg); break; + case SGX_IOC_ENCLAVE_EXTEND: + ret = sgx_ioc_enclave_extend(encl, (void __user *)arg); + break; default: ret = -ENOIOCTLCMD; break; From patchwork Mon Apr 12 09:04:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raoul Strackx X-Patchwork-Id: 12197271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A69FC433B4 for ; Mon, 12 Apr 2021 09:07:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 310B7613B1 for ; Mon, 12 Apr 2021 09:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239647AbhDLJH4 (ORCPT ); Mon, 12 Apr 2021 05:07:56 -0400 Received: from mail-bn7nam10on2137.outbound.protection.outlook.com ([40.107.92.137]:11584 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240380AbhDLJFw (ORCPT ); Mon, 12 Apr 2021 05:05:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kNnIZFtZfAlmJwcY60gM5zGHEkdJgsMbPccWu5Ko/BdwbZxGRYyJkzu1Z+jVU4FvBws7zPanPLo0u8VHRXwVtvIxJIRIo+fAL2bFJn4gFbZenYqY8HZKp/xRp+5kkk0GL646NjUq0+h9oYDls7nGyYTTc6HeV+4JB1XRdjB3WpTgCz2Uqsr8Pyw2/h0+zdy5TJF3rjFXVETM4R50brLf5hnaKiyGNWrMgIa7z1dowYBLym2kbdg/90fNe2AETeWLrr15JgWpo6Hgdon5kRAYDM0tzGeGNusOk/PLqryjt6WHvuvJ0Z5UWSH1Hp5prKDXeZChU3IG4lHBZEqoFqn0rA== 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=WJWBrtQh9aORyFSZJY28iwxDc+kXJPC8VEn56mdRRkA=; b=F2oe4qVRjDhg9Mwm3lYNdZnBkaywbln26AZOulJ4eKa+2atBZlIfo1S7pmfqR9pSLZ8ywp2+zZVqFkC9ujeDR7721EdRDuSGF5smbkrwA7oIi5noTQx7R5zHIgw633YbIoG0kcT2KvOr3swE1m8bl7k63kYpCQChTP8t3zEvWLBnljcEYfHURmxXQEM+XYPd7y130WNKGAnw9QVYeeLttk3ITA0YOZ28EzpaFkL7Ic7hL8va/vRU40Ogbd5+I8fg4xK9EAmkLATTwFSAtqBD3IwOjFg12cw4PneZcDBBCGQiEjv2lxCo88vQQn0ZI4SpMowHLdh74Tev8tII+p11Ig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fortanix.com; dmarc=pass action=none header.from=fortanix.com; dkim=pass header.d=fortanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fortanix.onmicrosoft.com; s=selector2-fortanix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WJWBrtQh9aORyFSZJY28iwxDc+kXJPC8VEn56mdRRkA=; b=TD1Dev/03+19oKHqvjeDQ+bFNe4jiCyeZodB6mFcGeropcg6zNwvCE5iKgBCRFYHU1zFP0cByRiKVLnIqFQSt868229UjwrVjmWiQnfV+5eFXYVMAhKu5auIQfX+gegwR2z8OxzthPJFXWJ6TimOlidBitkpR4iE7oOdXBZSaSA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=fortanix.com; Received: from CY4PR11MB1783.namprd11.prod.outlook.com (2603:10b6:903:11d::20) by CY4PR11MB1384.namprd11.prod.outlook.com (2603:10b6:903:2c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Mon, 12 Apr 2021 09:05:01 +0000 Received: from CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::f052:14fe:c2a9:5fb1]) by CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::f052:14fe:c2a9:5fb1%3]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 09:05:01 +0000 From: Raoul Strackx Subject: [PATCH v2 2/3] x86/sgx: Fix compatibility issue with OPENSSL < 1.1.0 To: Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org References: Autocrypt: addr=raoul.strackx@fortanix.com; keydata= LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgptUUlOQkYyb2lmOEJFQURN UkFMT1ZjRkYyTlQva1FsWTBtVnN3YlMrYi9WNzR1azZFcDdxenpoNHpHbEtSS1pzClplS0I4 WmpFT2h5Q2pZaExwdnJHTVh2cTV1bm5pWENIbG9BR1hZRm9rN0Q0SGd2Q0djYnlTYVRMQjds NHc4MFIKOStYUkp2SnJpMEdPSmVubjRnNUpIQU5RN2h5YWl5RlRIYTVERU5CMjc2VG9kZUFQ bnVidGl1VmRDT0lnQVJVbAp1dzJHemFsbmY0WmZ1TGdEaHg5YzIza2pjZTFBQkFWbWdxUEtN TkVUSnhyZFdLQUt5QkVIWGJ0Snh6YnR4bFI1CnFUZU8yTExCU2V4TFBDbTRZOTZzRHlGK3JJ a2FpRk5JQWk2b3RrTFBxYkROUlB4OTdLTTkzcmh5dVpIaWVQM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2wKaEwxMDArdzZNTWNMeFpNVmJ4UHBTWWVHaGp4SjdNUysyeGp3eDB4MWlMNmszZk5UNHNT Q3dZa0xRZjJlKzhxYwpFYjNTa0Q0VFR3RDQxUW85SFNuUlkwdnRqblNyZkwyQ3JhVmptOXhh MXhmNlJDQ3kvaXpKNU5TQTZZMXduT0U3Ck1IOHorcVFUM1NxMld0a0NzU1M5K1U2VU9OWmFK dFN5MWNvZ1ZhMDV1QWdRY0tHT3FvcHg3QWlmZUhIUFpqZnIKakVNaHJZQ3Q5WXgzR1VET0hs MnRObDJIOStqZC9BVjByMDRKUTNxSHRWM1Z5UTNxN0N1UTlCTTdnQzVpK1JleQpHSU14Zm0v a09GWTRLRUxOeVYrV01PK2lXRHpZS21tTUxnUkVXNitqZk5jMzhrYWhaQjI2RmJOZTh6QmxU cVpPCmhxYmNZR1ZZNW9Ec004YSthbkwyZDhmaStnPT0KPW9ZT0QKLS0tLS1FTkQgUEdQIFBV QkxJQyBLRVkgQkxPQ0stLS0tLQo= Message-ID: <92282c72-5849-70d0-1553-548130fba2bd@fortanix.com> Date: Mon, 12 Apr 2021 11:04:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Language: en-US X-Originating-IP: [81.164.43.210] X-ClientProxiedBy: AM0PR10CA0040.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::20) To CY4PR11MB1783.namprd11.prod.outlook.com (2603:10b6:903:11d::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (81.164.43.210) by AM0PR10CA0040.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 09:04:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e93b891-217c-4247-3132-08d8fd920de4 X-MS-TrafficTypeDiagnostic: CY4PR11MB1384: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1360; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RUcQfen7JDgN1mrV4c2OmpZsU06JmgAqSlR8Yw6jEG0919kNgCHeXsmWdCk2gqLZfPDmAGhPxJXTB43k2E/mfKcNwM616fio4Le5ySrodKaPHaP6W3cuAdOP3HT/Ql0FZ8v7RMXbQn2fbd5uLI4/FpOit18IB8HZrDV8zzZSdouQiHQmtf0QI0BgJDnx6KsTvw9CKYmgOc+jFxtoNLL4reEBk9s96uNtH+B15hq6NClrR/OZit4ksNWMiF7gjjSnWq3mqViV0IVhd5Pw++pzTUzZwAzO5cPYvBjEikp5ygGH/M6aitvq2R9z5ZPn00ClUc2baykTDCIAGhS4Gt7QOL5gn16uTXQhD3xlPRkg+fYf8R7S+BsQFAb3/y9715v+Sj80NpMOZNjkjVcId+dnvUVfphUwRSFKwEN1TI9HkgIC71N9QNduu2mkTXsR5uZ/ca0dxYcxOZR7TRqcGVHYjoonNIA0QJtfmYWiCkO98CYfkwC47cw8tg7hXj1PQ2+WsCQ5iLC+xgOMnbrT3JzFc2psM5ZWebxvamuZYo/6g7RrG8TjxcLeXITz5xxpomkBGZoRRNZh2BHvpZLwd+NWEgyqajoRwGm0TX+w5xPGfjDVeeDUD0gVYtAkgo1oH+/Somt6z2+bvInXKB9pIkg/KDz2XyRRLJvcXCA8iYlgqyB12DeCr0sPcTMRRur6FPPbnUa3wHI16HEJ34geitNf8OnAu28RpZ+kJfrgQG4MPKw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1783.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(39830400003)(376002)(136003)(396003)(366004)(26005)(66476007)(4744005)(6486002)(186003)(16526019)(66556008)(44832011)(5660300002)(2616005)(38350700002)(316002)(86362001)(6666004)(956004)(66946007)(52116002)(31686004)(8936002)(8676002)(110136005)(36756003)(16576012)(2906002)(83380400001)(478600001)(38100700002)(31696002)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?m4GRhxFK1groM1yPdezwUZ6hlNBMoe?= =?utf-8?q?SW236Ac0uQ7rPXbvUZQM1r3PqAJEbaGTfS1Z2yiieU+0NEmwicF3arAnm8v3hSXTh?= =?utf-8?q?hrakeVTaFUacs7vxMDgw9dgFuZ6TTr69LoiuehtWLLZjVlPYPzBMj3UkL9MJqDev7?= =?utf-8?q?WciX8sJVjWc4PFlGQoGacX9SYtLRmjPv3PBaPP3zxvHSZeVOIGbOpilUrfvt+/jek?= =?utf-8?q?xPo5JQKAJSBWgFD8k4sXjuANQt3vAYZt9fPfxpf5ETPrISQyPSKKONouNs/EUAZAw?= =?utf-8?q?DCp8T6vnhesP1AK82D68Qv3rAXlgk42eja9IyJbG/OSGbfKzjQMyel7/lFFX1TLy+?= =?utf-8?q?GB9WZXcwtgLZsKAtJgvQWzcH/0RGZ7qZFUV3q+G2Aa5wFka73MvCGlWVSowkUYW+Y?= =?utf-8?q?/4Op1lW9yzXEGOT8SFhM1PNBuy5A2dOkfBdn1K6ZUYIso7YU3aXHrrJTC+UiRfoqv?= =?utf-8?q?jZ0ILXSjjVQFS1YrQpka8pt3mfOi/oc9w8Cdy6R4GhCcBTGRyq6pc+G221174IapY?= =?utf-8?q?FAwVysTrIyTcBzutaZxzsgCnPChOPZ3Y20UHD9N7BeBjSWSSX/pLVte7EFGfBJaxE?= =?utf-8?q?UB0L0PuY6sI/bpSdvakuCPOYKmelhzQALUmhZeJ7ya1okomIp2jGM0ScmgL7hpPym?= =?utf-8?q?1cTWYhtN3sP543iwMYJY9lCiELq9d9KIHAC394VQBbiuYdUrZdFJrjIP85EF06Ca4?= =?utf-8?q?XApG6zN/bFEujEEJsXPhmo//e4MgtVwwF5NBMW2KVSVgq2HOu39+IEdbrE2DWFdNp?= =?utf-8?q?rX+VJfpW3tgLI4jf/U/G6ohoX0/5WlEOPr64YOsdYKf/ydVYeUByWkYvxgv87FqCB?= =?utf-8?q?QKQD6imopUZyG96gd0Uh15pEVi/W3gnWLjifV34SXqW8EsYMHPgz5/KkTk4WScvUt?= =?utf-8?q?EyeNsamkfwDJ//OvgBqAKYjdqCT+DL+ENu+MNHIvGgJShltjy3qfIxBu2C9nzPoRT?= =?utf-8?q?tcsHON57PzLJEq7KHVp8jgXkJ+mZXHPJ3i4s9kJytRMFQmJnwq+ZbOPYFznO3O/+L?= =?utf-8?q?WNPzVJml9Y+9NNH3RFRhzeYo1Nb1w7jaBhoHdITa/HwOeUZV2nXMRsNWT6FZCUCs9?= =?utf-8?q?iMOkiZfmSIv2S/ruWdIiI9V/3ay8cijT1+X5Lq86Om2xMPavm9FBTfnTmkxP0gW4p?= =?utf-8?q?gnVVL6uwcUaBW7yxTqlokdZFNo+KqJst+sisnOMhHKmJww3KSwxnhvlcQ+EqpdBAs?= =?utf-8?q?m+NcVou+Sp+Kz9cD/FhPTIT5QqxPmNOZEeTu1LztsjHdkXUhmhQtHNQmosK8y0Ba+?= =?utf-8?q?d1Fip6MfvM3bFj?= X-OriginatorOrg: fortanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e93b891-217c-4247-3132-08d8fd920de4 X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1783.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 09:05:01.4995 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: de7becae-4883-43e8-82c7-7dbdbb988ae6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lLpcjU9NpimaF4e0jb4yQWYBwCay6QHYjbGKeW2Fve0mnhoJ9hYKwKMc5KHDP52L4SaNw1JytSiT2i7f2FqqEnODusFE4g7br2VCNvYusOM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1384 Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org The `RSA_get0_key` function only got introduced in OpenSSL 1.1.0. This makes compilation fail with older versions. Signed-off-by: Raoul Strackx --- tools/testing/selftests/sgx/sigstruct.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/sgx/sigstruct.c b/tools/testing/selftests/sgx/sigstruct.c index dee7a3d..aac9cbc 100644 --- a/tools/testing/selftests/sgx/sigstruct.c +++ b/tools/testing/selftests/sgx/sigstruct.c @@ -128,8 +128,11 @@ static bool check_crypto_errors(void) static inline const BIGNUM *get_modulus(RSA *key) { const BIGNUM *n; - +#if OPENSSL_VERSION_NUMBER >= 0x10100000L RSA_get0_key(key, &n, NULL, NULL); +#else + n = key->n; +#endif return n; } From patchwork Mon Apr 12 09:05:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raoul Strackx X-Patchwork-Id: 12197273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CD6BC433B4 for ; Mon, 12 Apr 2021 09:07:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1669B613B2 for ; Mon, 12 Apr 2021 09:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239693AbhDLJIA (ORCPT ); Mon, 12 Apr 2021 05:08:00 -0400 Received: from mail-dm6nam12on2125.outbound.protection.outlook.com ([40.107.243.125]:21408 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240410AbhDLJF7 (ORCPT ); Mon, 12 Apr 2021 05:05:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UdtQiae4CiTlqk25m8FCCdg4Ve0p5XYyoyugg8R1CZddoSWlBDeRCbMrT4Nn1B4LI7eJgc+nGSQtpaQQfLliKN3JEOYC799ja2iSNF02R8uVKw7Wmcr/4MnTuXDIJnaR+ona+yA8lopazaCqIjjNlF5eBuplAc18thnEPrTI2dLgcpn/BcDyrFjZ7K+gHPW8Rn5nafxJLh6cG36aKNjL8FJFnzNutEcDf2Ykv91qqh2yIsOQOUDZmFRgGLGeXSWFzSAAnGUCz+EbpW0H19RhoOfvvxo++puaY5xrEuAApMpufrY25omH+SXolFJJHNul7IIQDq5O+EyHEF1qlHWNZQ== 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=0TIMyh1T7JtlOImyWg9N1qmyoboI7O2xx1L9OBV80WA=; b=ln/B7skjQnHMZL0haMEMS+spALykwLGbvZJoTMa4orkuGGdFncluy+P1uUYsWVhK2V8jtGJkuBL9xrTXTNGL7YcYJRm/J4UJI46ysSXzt5b8hqc86COxctuo0ipTGfBQtQCWjBQIynL8+B5moMKW3i1soZHvnW6yvNk/RwHZ7tf8LgDxyhMRXq9c5s7HlTfa4AfKC8JTOKqjzCvl4S7cyjnCY0/nONrDiqsWnf+K0UN8jV6h/QB9iyxyYDzsClVYQ/NXeIlLoKGsCTAu+DZvEDDfi3cRyIkEVHElnnNOY0urCYf60LcKtdNnw1b5K/996ije67eOOcve/zqhLgWtpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fortanix.com; dmarc=pass action=none header.from=fortanix.com; dkim=pass header.d=fortanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fortanix.onmicrosoft.com; s=selector2-fortanix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0TIMyh1T7JtlOImyWg9N1qmyoboI7O2xx1L9OBV80WA=; b=amGMm+5UujIHQWWbjeG0J768uuboRyq11Weg0bCCB7gmpGJCUl0xpbuRZewFtaxbO+pNQpOsOj5+qujQtoBqTafX+S9CdzMmSuKiyeuODeRk/E0QSyo/CVCUzmbncFr6atAU8adPaxyvxeDoxFkXORGPUPOj1pUR4fZClCXBQdA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=fortanix.com; Received: from CY4PR11MB1783.namprd11.prod.outlook.com (2603:10b6:903:11d::20) by CY4PR11MB1384.namprd11.prod.outlook.com (2603:10b6:903:2c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Mon, 12 Apr 2021 09:05:25 +0000 Received: from CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::f052:14fe:c2a9:5fb1]) by CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::f052:14fe:c2a9:5fb1%3]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 09:05:25 +0000 From: Raoul Strackx Subject: [PATCH v2 3/3] x86/sgx: eextend ioctl selftest To: Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter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UEdQIFBV QkxJQyBLRVkgQkxPQ0stLS0tLQo= Message-ID: Date: Mon, 12 Apr 2021 11:05:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Language: en-US X-Originating-IP: [81.164.43.210] X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To CY4PR11MB1783.namprd11.prod.outlook.com (2603:10b6:903:11d::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (81.164.43.210) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 09:05:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4b277c64-2977-4d30-bfca-08d8fd921c31 X-MS-TrafficTypeDiagnostic: CY4PR11MB1384: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RJXKH+bZzhcVZisvDlT/PpoE498M5uFjdFxQe+sI/0RsvWUiMDlbpQVJEDvE5jLP8chfWSaSUNA97cmBqg9qZoE+httsOwRSpA8I0EEuF0Zzk+7FE64lzvzKdnLYYe6LydTkRAqeQouziJXcjPU6NfaxsVC32BfIgRPDsF+weyPGKGYIl+R5810A0qi4WSrurIzk7HAAte+DC3bwxofwkT/LvpoQ8vww8zt6oDJQE8cDf+Lv8bMu0GmbIVfY+nQQ8mrERKRbiZB63W6jiphMtLy8H8BZY8E5IMyxcSo0DETkm0vnX6rugRa5SqFZ+z/kfYBcFPhNE+hweRsmCWu0EVWviMWDRY4rb8RcXkida8kQU3qC9UM7eC/YeCR/FvPfELosSp4CFKFE5+IMYx5YNf8eHgzKcSRnNOic4XsFzOcNc3nPnUvH8mvMWdCHrhPPVncZKbjBWw6wOkMgBODWCsLcuwpZFnl0iycfNX8W3qRBXsXgI8kUwrvV0ygC3vip1PCotACjmEgiRCN1YwHavNjXJUwNFqLbypCzvUSRPuz1km7Z70G0hMKPfpv/NJMXvyhCXhMEMiadzh1YX7/0BaMmdQLczp+EYawr+nNVJphzTS0ybcz0gMqVS4ES1T7VtXRYamonvU4lj66yM2oGmB/zD3d4GEil3tGOfcqGLX/n9JYuvR97EfTfPOEew6yUQZ1y0ejeHRz2YXtrd33izUEFsgi/4M1M0lvxVwY00SI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1783.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(39830400003)(376002)(136003)(396003)(366004)(26005)(66476007)(6486002)(186003)(16526019)(66556008)(44832011)(5660300002)(2616005)(38350700002)(316002)(86362001)(6666004)(956004)(66946007)(52116002)(31686004)(8936002)(8676002)(110136005)(36756003)(16576012)(2906002)(83380400001)(478600001)(38100700002)(31696002)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?nUS3mR793NWU3+cmbclkTQYlbki0/v?= =?utf-8?q?GULT0Tn4mkYAzhTQv7ggykc8W9lE2p0tfGRNjKTSYtJ9kCcWIYEQCajQjZaNTIvI9?= =?utf-8?q?iN2EaLPKkIx9sc1+2XcSqJG9yrCblRdLzXGpuFMSDj0INR6mpdZQHAWC8fQJ8b8mB?= =?utf-8?q?R/5/4stE5aFP9dpemBXTRfekIJt8c+8bd6VEhfP+NVpgiDuiJA82FxMUS3qUJH85i?= =?utf-8?q?3ELoe3dXbkNjhYXecjJRG9W6HSXQgvZMx1VdQ2NlQg6T4RkFh8LQTYmze4MN3GHlq?= =?utf-8?q?yeWQta5CbCe8hCW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0ToFHuS6kfaxBWc9jqOMYJV362aSMMzuaTe1JHUV8Nc7PoYl?= =?utf-8?q?1dESmu6zIi2dHcRF18axA3Hhr3jxkmK0gXwOU3ZKx3sgpFUy1d+4ojwdcHBvJMBSP?= =?utf-8?q?BBgAYu92zxCZEZ?= X-OriginatorOrg: fortanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b277c64-2977-4d30-bfca-08d8fd921c31 X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1783.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 09:05:25.5139 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: de7becae-4883-43e8-82c7-7dbdbb988ae6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0wWAfBmcR+UJOyDaFugcZtCrh8OcznnjAOuX4Hhk8qzdhkAJ2y3/GDqccNCsbI7SkuL6D9RV1Nl4goyGcendxReThj9zVliamPCNNNH6ob8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1384 Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org In order to test the new eextend ioctl, the SGX selftest is modified to only partially measure the last page of segments. Most segments are larger than 4k, so the MEASURE flag for SGX_IOC_ENCLAVE_ADD_PAGE is still being tested. Signed-off-by: Raoul Strackx --- tools/testing/selftests/sgx/defines.h | 1 + tools/testing/selftests/sgx/load.c | 57 ++++++++++++++++++++++++++++----- tools/testing/selftests/sgx/main.h | 1 + tools/testing/selftests/sgx/sigstruct.c | 38 +++++++++++----------- 4 files changed, 69 insertions(+), 28 deletions(-) diff --git a/tools/testing/selftests/sgx/defines.h b/tools/testing/selftests/sgx/defines.h index 592c1cc..c09550d 100644 --- a/tools/testing/selftests/sgx/defines.h +++ b/tools/testing/selftests/sgx/defines.h @@ -10,6 +10,7 @@ #define PAGE_SIZE 4096 #define PAGE_MASK (~(PAGE_SIZE - 1)) +#define SGX_EEXTEND_BLOCK_SIZE 256 #define __aligned(x) __attribute__((__aligned__(x))) #define __packed __attribute__((packed)) diff --git a/tools/testing/selftests/sgx/load.c b/tools/testing/selftests/sgx/load.c index 9d43b75..39484fc 100644 --- a/tools/testing/selftests/sgx/load.c +++ b/tools/testing/selftests/sgx/load.c @@ -102,28 +102,69 @@ static bool encl_ioc_create(struct encl *encl) static bool encl_ioc_add_pages(struct encl *encl, struct encl_segment *seg) { struct sgx_enclave_add_pages ioc; + struct sgx_enclave_extend ioc_extend; struct sgx_secinfo secinfo; + uint64_t size_full_pages; + uint64_t size; + uint64_t chunk_offset; int rc; + size_full_pages = size_fit(seg->size, SGX_EEXTEND_BLOCK_SIZE) & PAGE_MASK; + size = size_fit(seg->size, SGX_EEXTEND_BLOCK_SIZE); + memset(&secinfo, 0, sizeof(secinfo)); secinfo.flags = seg->flags; + // Add and extend full pages ioc.src = (uint64_t)encl->src + seg->offset; ioc.offset = seg->offset; - ioc.length = seg->size; ioc.secinfo = (unsigned long)&secinfo; + ioc.length = size_full_pages; ioc.flags = SGX_PAGE_MEASURE; - rc = ioctl(encl->fd, SGX_IOC_ENCLAVE_ADD_PAGES, &ioc); - if (rc < 0) { - fprintf(stderr, "SGX_IOC_ENCLAVE_ADD_PAGES failed: errno=%d.\n", - errno); - return false; + if (ioc.length > 0) { + rc = ioctl(encl->fd, SGX_IOC_ENCLAVE_ADD_PAGES, &ioc); + if (rc < 0) { + fprintf(stderr, "SGX_IOC_ENCLAVE_ADD_PAGES failed: errno=%d.\n", + errno); + return false; + } + } + + if (size_full_pages < size) { + // Add last, partly measured page + ioc.offset = seg->offset + size_full_pages; + ioc.length = 0x1000; + ioc.flags = 0; + + rc = ioctl(encl->fd, SGX_IOC_ENCLAVE_ADD_PAGES, &ioc); + if (rc < 0) { + fprintf(stderr, "SGX_IOC_ENCLAVE_ADD_PAGES failed: errno=%d.\n", + errno); + return false; + } + + // extend chunks + for (chunk_offset = 0; chunk_offset < size - size_full_pages; + chunk_offset += SGX_EEXTEND_BLOCK_SIZE) { + ioc_extend.offset = seg->offset + size_full_pages + chunk_offset; + rc = ioctl(encl->fd, SGX_IOC_ENCLAVE_EXTEND, &ioc_extend); + if (rc < 0) { + fprintf(stderr, "SGX_IOC_ENCLAVE_EXTEND failed: errno=%d.\n", + errno); + return false; + } + } } return true; } +uint64_t size_fit(uint64_t size_in_bytes, uint64_t block_size) +{ + return (size_in_bytes + block_size - 1) & (~(block_size - 1)); +} + bool encl_load(const char *path, struct encl *encl) { Elf64_Phdr *phdr_tbl; @@ -197,7 +238,7 @@ bool encl_load(const char *path, struct encl *encl) } seg->offset = (phdr->p_offset & PAGE_MASK) - src_offset; - seg->size = (phdr->p_filesz + PAGE_SIZE - 1) & PAGE_MASK; + seg->size = phdr->p_filesz; printf("0x%016lx 0x%016lx 0x%02x\n", seg->offset, seg->size, seg->prot); @@ -209,7 +250,7 @@ bool encl_load(const char *path, struct encl *encl) encl->src = encl->bin + src_offset; encl->src_size = encl->segment_tbl[j - 1].offset + - encl->segment_tbl[j - 1].size; + size_fit(encl->segment_tbl[j - 1].size, PAGE_SIZE); for (encl->encl_size = 4096; encl->encl_size < encl->src_size; ) encl->encl_size <<= 1; diff --git a/tools/testing/selftests/sgx/main.h b/tools/testing/selftests/sgx/main.h index 67211a7..9d63bda 100644 --- a/tools/testing/selftests/sgx/main.h +++ b/tools/testing/selftests/sgx/main.h @@ -34,6 +34,7 @@ void encl_delete(struct encl *ctx); bool encl_load(const char *path, struct encl *encl); bool encl_measure(struct encl *encl); bool encl_build(struct encl *encl); +uint64_t size_fit(uint64_t size_in_bytes, uint64_t block_size); int sgx_call_vdso(void *rdi, void *rsi, long rdx, u32 function, void *r8, void *r9, struct sgx_enclave_run *run); diff --git a/tools/testing/selftests/sgx/sigstruct.c b/tools/testing/selftests/sgx/sigstruct.c index aac9cbc..eba7c86 100644 --- a/tools/testing/selftests/sgx/sigstruct.c +++ b/tools/testing/selftests/sgx/sigstruct.c @@ -260,28 +260,25 @@ static bool mrenclave_eextend(EVP_MD_CTX *ctx, uint64_t offset, const uint8_t *data) { struct mreextend mreextend; - int i; - for (i = 0; i < 0x1000; i += 0x100) { - memset(&mreextend, 0, sizeof(mreextend)); - mreextend.tag = MREEXTEND; - mreextend.offset = offset + i; + memset(&mreextend, 0, sizeof(mreextend)); + mreextend.tag = MREEXTEND; + mreextend.offset = offset; - if (!mrenclave_update(ctx, &mreextend)) - return false; + if (!mrenclave_update(ctx, &mreextend)) + return false; - if (!mrenclave_update(ctx, &data[i + 0x00])) - return false; + if (!mrenclave_update(ctx, &data[0x00])) + return false; - if (!mrenclave_update(ctx, &data[i + 0x40])) - return false; + if (!mrenclave_update(ctx, &data[0x40])) + return false; - if (!mrenclave_update(ctx, &data[i + 0x80])) - return false; + if (!mrenclave_update(ctx, &data[0x80])) + return false; - if (!mrenclave_update(ctx, &data[i + 0xC0])) - return false; - } + if (!mrenclave_update(ctx, &data[0xC0])) + return false; return true; } @@ -289,12 +286,13 @@ static bool mrenclave_eextend(EVP_MD_CTX *ctx, uint64_t offset, static bool mrenclave_segment(EVP_MD_CTX *ctx, struct encl *encl, struct encl_segment *seg) { - uint64_t end = seg->offset + seg->size; + uint64_t end = seg->offset + size_fit(seg->size, SGX_EEXTEND_BLOCK_SIZE); uint64_t offset; - for (offset = seg->offset; offset < end; offset += PAGE_SIZE) { - if (!mrenclave_eadd(ctx, offset, seg->flags)) - return false; + for (offset = seg->offset; offset < end; offset += SGX_EEXTEND_BLOCK_SIZE) { + if (offset % PAGE_SIZE == 0) + if (!mrenclave_eadd(ctx, offset, seg->flags)) + return false; if (!mrenclave_eextend(ctx, offset, encl->src + offset)) return false;