From patchwork Wed Mar 31 12:18:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raoul Strackx X-Patchwork-Id: 12175375 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 537F3C433E5 for ; Wed, 31 Mar 2021 12:20:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33FCC6199A for ; Wed, 31 Mar 2021 12:20:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235286AbhCaMTj (ORCPT ); Wed, 31 Mar 2021 08:19:39 -0400 Received: from mail-mw2nam08on2110.outbound.protection.outlook.com ([40.107.101.110]:19361 "EHLO NAM04-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235458AbhCaMTS (ORCPT ); Wed, 31 Mar 2021 08:19:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jjWbfRxoolVdFRmc0wFRWNQEOwX0Ms4n9e7Ag5a5ZMLwG4hbVSLeSqIpk6wNFcHxL7mHEs8oFoTTHGnQfB6mxyEW5EASrC+Wm6SGTCKyCrEmJWAjJAUG2+xicaKnCulZbXteIeXLejI3VH7/hDiyynVwiXi9t1ayizg3x6rVCFODdln2awi8VeMB4uG30cfv8L3KMB5x47f78+1diOz6aLw6OkUkPG68AFGPwRTP+hodPNXCm8/yMYAHs9fr8RIm/50JEF+R9zerttrcT0D91bY8MZE2JysOIQ+GNGq5SvZ/l4TBSPD09Un1tVyHkERI8PY3iqkqNFwOLkVGs6W6Kw== 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=QqIDBIId0r/jciEbDQvNbqQw3t1U1ULHQU6gI9otkho=; b=QyDmgNXA+MmcRD9SNphkXYT0XL7IK9ny6mOn8Li19+VNBsQffULogzoFAgy9FVqCpsMP/iKxFCjrvPBL7QbGV92B37B7o6C3IRtfXaCgbX+CZ9EOm4SE8TaDWkPdpvwLSwXIEGIhROLJ5x8VKMrq5tx6cPgLPnjeWhFVOCPpPRez0ie7cY3ssaXtWF8+3qjxtAbVq+SLdLMVYRCJCPsIiuAD9ILPujK4KSq1AhjUZOa269I7NwzkZxNWIuyL1b8yfN+VI9R06ECwB1h5Z8SRHcZU9Ps/Gpg4B0gVmzpwE0U+9SiokNCp/AHdeXG48XcOAgZuSsStobSYOvKW5qZ3kg== 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=QqIDBIId0r/jciEbDQvNbqQw3t1U1ULHQU6gI9otkho=; b=H6ii+JY/elM9/c6HqtrTrpj7rChGfaO3O8EmtrHhzO9DFcCiPIgvheDvY2Y1yrX+e5HnKXF/ZTt2Bc8LXWKJzGuhl/D3NL4KBba1r6aWzGMRic6lHD5UtEWoaXYZY+4WJoKSTatwWSpGdrIHmWyBJqcnjIg00yU9pnsxAGolnlM= 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 CY4PR1101MB2312.namprd11.prod.outlook.com (2603:10b6:910:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.30; Wed, 31 Mar 2021 12:18:57 +0000 Received: from CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::6dcc:f099:6ba8:6ebe]) by CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::6dcc:f099:6ba8:6ebe%10]) with mapi id 15.20.3977.035; Wed, 31 Mar 2021 12:18:57 +0000 From: Raoul Strackx Subject: [PATCH 1/3] x86/sgx: Adding eextend ioctl To: linux-sgx@vger.kernel.org Autocrypt: addr=raoul.strackx@fortanix.com; keydata= LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgptUUlOQkYyb2lmOEJFQURN UkFMT1ZjRkYyTlQva1FsWTBtVnN3YlMrYi9WNzR1azZFcDdxenpoNHpHbEtSS1pzClplS0I4 WmpFT2h5Q2pZaExwdnJHTVh2cTV1bm5pWENIbG9BR1hZRm9rN0Q0SGd2Q0djYnlTYVRMQjds NHc4MFIKOStYUkp2SnJpMEdPSmVubjRnNUpIQU5RN2h5YWl5RlRIYTVERU5CMjc2VG9kZUFQ bnVidGl1VmRDT0lnQVJVbAp1dzJHemFsbmY0WmZ1TGdEaHg5YzIza2pjZTFBQkFWbWdxUEtN TkVUSnhyZFdLQUt5QkVIWGJ0Snh6YnR4bFI1CnFUZU8yTExCU2V4TFBDbTRZOTZzRHlGK3JJ a2FpRk5JQWk2b3RrTFBxYkROUlB4OTdLTTkzcmh5dVpIaWVQM1gKNWY5dG8vN0xEcGhqV0ds L0ZBcldmT2U1QTgxTnhoTG5GNm9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eDB4MWlMNmszZk5UNHNT Q3dZa0xRZjJlKzhxYwpFYjNTa0Q0VFR3RDQxUW85SFNuUlkwdnRqblNyZkwyQ3JhVmptOXhh MXhmNlJDQ3kvaXpKNU5TQTZZMXduT0U3Ck1IOHorcVFUM1NxMld0a0NzU1M5K1U2VU9OWmFK dFN5MWNvZ1ZhMDV1QWdRY0tHT3FvcHg3QWlmZUhIUFpqZnIKakVNaHJZQ3Q5WXgzR1VET0hs MnRObDJIOStqZC9BVjByMDRKUTNxSHRWM1Z5UTNxN0N1UTlCTTdnQzVpK1JleQpHSU14Zm0v a09GWTRLRUxOeVYrV01PK2lXRHpZS21tTUxnUkVXNitqZk5jMzhrYWhaQjI2RmJOZTh6QmxU cVpPCmhxYmNZR1ZZNW9Ec004YSthbkwyZDhmaStnPT0KPW9ZT0QKLS0tLS1FTkQgUEdQIFBV QkxJQyBLRVkgQkxPQ0stLS0tLQo= Message-ID: <1b002a72-139d-0ed3-28ea-0d4980e110f3@fortanix.com> Date: Wed, 31 Mar 2021 14:18:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Content-Language: en-US X-Originating-IP: [81.164.43.210] X-ClientProxiedBy: AM8P191CA0027.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::32) 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 AM8P191CA0027.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27 via Frontend Transport; Wed, 31 Mar 2021 12:18:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9512ee9e-9fc0-4864-d387-08d8f43f2868 X-MS-TrafficTypeDiagnostic: CY4PR1101MB2312: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hZ5EOp0SSGXdobulh11mTbksUqmV7tJjW6kOgqW1T2x9dhjw/eSVbbyP9VSdcczYaSZby6XYzvFptpn7cRXPJ9I+J54wC5BpMzkORMqrgbyorPzaR0T0XVe42zAVtPdNWeqYPFko9jw/rpwn8pfYvddaxnjPYoIkMSXaH8STvMC4LLfSu4tyjn40oJ05NczejaKNu5kYsSGw8ZtoZ2XipQG2hZjh4Qe8wC3BRfR12Jy1lH6wdTaziINbjuUUrPH0wkhQh+2ig2hLKzgdpiKPaAw/B4Yy8UQbWC1sXm4DyNSoQ4McFOGACRZq5acX4HGf/E7sFgC4sqTevcToYQHNvsEFYIBZ5WkkSdw2ekjK5UQrvVlqi3WZyhN4mD55swvBLVkSCsC5BXTc1IGhY3enNBZDvi1QMceBOKa3qB7rHDtArUHyDSjVObP1zuJukWD8yuD12nBLJq6DYw8jHaszKnNDUKQxGH6ynF6zwUqNc825y0JwVmS3oVt1Xe6rZNSgW/0k3kc7DEfFNjBgRqL89QDjVyfXTUF43lrKCBUI6PbhV2cP0Y8B6TuqNABp0RDH4e0MXwk8EtFncsnmkRXH7/GCcUrRmbyP4zQjLKPuTQ5es+5COkVEyXNNtMlRbUCEkTJZKSpcp02hM2UrO1RiLLHqhsTWeSXjOyOWBeP0sZuR8HHE+lXcDIQGrQQlQv7aXnYEbkZ57YcKz1z3Wmjs3zkgFnL3Ln7XY+xniTGbZkw= 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)(376002)(136003)(366004)(396003)(39840400004)(66946007)(2906002)(52116002)(2616005)(6486002)(5660300002)(8936002)(8676002)(956004)(36756003)(316002)(44832011)(38100700001)(66556008)(66476007)(6916009)(83380400001)(86362001)(6666004)(16576012)(186003)(26005)(478600001)(16526019)(31686004)(31696002)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?lVj9lSw/DOkxK7agoRAqeAWH9awDZg?= =?utf-8?q?vigX4g2uhF5bworEL66r2aMVyXiNuutRDBIqBOSdwSgOEvTc30GdWpV9ZFEAnfFP1?= =?utf-8?q?AjTKmAxZRrgSCIrYcJBWkeF02H5/OYEwwQ8J7dy4BnqmmmrAAStV9V8dH/QuglO6t?= =?utf-8?q?I5GwxXA2Hxa/QRwSknlaHDFJuZnRqavOQxhYz+gqGSakJ1TKOkJG/t0mijsWGiU9B?= =?utf-8?q?Bvyr/534PsR17jvow5+8vcIjDd3TprcVOehRw3SsToC9IlbKXtYIcgyu59HCxK2UL?= =?utf-8?q?heHdiUCkjZ+IIBZah4a6Y/V1vMHSIiSIbkotBVnkv681vOsqXDp1Xgz50vdYRSDe0?= =?utf-8?q?YSPSVxpIM6KF+HsFTunxTOwP5v0RSRoHyuWbwatOvRf7zQBDYqpBkPBnHjIQ6xj8p?= =?utf-8?q?jYSCpiofy99Wpq/xNLDjj2voRVd/T0mDRumOfOERqg3HqUyD6e4dSH48316qcKd91?= =?utf-8?q?ysOSpjsRilCDa/4Q7qgVNIQJFvKuzBDugsC54gc1YPiQ8q5tqRVl36s3/wU3sxLof?= =?utf-8?q?W3KHW3/BXphae02fglv5w8Z7lVmZkeXZU6Exp27MjO8Y7nqsT70rrmWl6niXYa5t7?= =?utf-8?q?nmihWDHh6Z4+f4kUoilGV9MAgBQs1G2aEv+qpbe6E0ulJArdmOWJuFaF8hPvpqZhY?= =?utf-8?q?WbevqfFf8HHyDQq/+W/b2aytMgC2QmJScYfc5twCfKqL30cnpko4oZLnEWc5eF+9A?= =?utf-8?q?FXtPewTF7bq59iGhPnExAk5Yz9e1s+Kn0lmcgQUdNuKdyjeN76FCgEiYQbJkbT+dT?= =?utf-8?q?rBz70/j2S3sAqX7VplQnxaLp6X6PLmNrev3haz3n9Jo6UI0aHZsUqW7FFiQJgCZk4?= =?utf-8?q?KeAb85zMCovXi/xk++Pdod78c76bB2sSgXbVQCyrRSWc/TKqGTM4cv6Skuhj9i0o0?= =?utf-8?q?SW5Uq/MPrTtNu7TNZKxAPsZ034IETc4mLBCWj5NXYPUd4xGSV/IAaY6jM0i/m9a97?= =?utf-8?q?2xZUnId+qCUVPRp6LJhy3tTieki8YtrZPtUFuQ4yzPtgp6qQ+PPK9g/bGafnL2+JX?= =?utf-8?q?Ua9xS2b7zConhROfaRjd4Tok/ZMdIz3nmJenzO4N7G+EXLtNHoGzdDxfVd9WEPqKE?= =?utf-8?q?jvGV6Jvk05wbCWXPMeaWyZBrywqir0LOR1e+Nl3qApT8CT+DtbcVBeC9HtpO0xJGD?= =?utf-8?q?DMaOWEXjVV5Q4NH+AJomGykzWjfKDiLVLwHXOY4dyZ4ZJdQCH1ct8Vm9oO6cdLNx+?= =?utf-8?q?wwTuCUxAJuR89UVAwCCvLEbxKH/YHNZfge83qUOlSca7bCKpJob6VaJVIbFtN7wE6?= =?utf-8?q?wpL9EcE/9jlgdp?= X-OriginatorOrg: fortanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9512ee9e-9fc0-4864-d387-08d8f43f2868 X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1783.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2021 12:18:57.3309 (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: dmEUFBbKrFURho6/U4ty4yrhVJ0SrsAHiWVc9+RW6GkOy1zvG6JDSnTcu2Wm+I83Rzmm1K5b2hWopC/LpYeMO/7pWLJCjwJhP05ojbxREmo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2312 Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org The current sgx driver can only launch enclaves that always measure 4K pages. That may not necessarily be the case. This patch adds an ioctl to enable users to add the enclave measurement per 256 byte. 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..a21d3e7 100644 --- a/arch/x86/kernel/cpu/sgx/ioctl.c +++ b/arch/x86/kernel/cpu/sgx/ioctl.c @@ -261,20 +261,21 @@ 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 +287,18 @@ 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 Wed Mar 31 12:18:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raoul Strackx X-Patchwork-Id: 12175371 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 34B59C433E3 for ; Wed, 31 Mar 2021 12:20:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA703619A7 for ; Wed, 31 Mar 2021 12:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235457AbhCaMTi (ORCPT ); Wed, 31 Mar 2021 08:19:38 -0400 Received: from mail-mw2nam08on2110.outbound.protection.outlook.com ([40.107.101.110]:19361 "EHLO NAM04-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235461AbhCaMTT (ORCPT ); Wed, 31 Mar 2021 08:19:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f5gp67nBJb2ibyG+tCUFK+JjbGzTFS1L5TZLdEHhlN0LLIQ9Gaze2GW724CmB8SrWohyjPiygPaZxkBfaZBt06crTS2shUm01SSI536NnRSbToHXMxB/rUK/rEIefaPbShoH/elaZ7Spuj31/TbBCbOTo+V7J2T05mR6T36Vc0fnBDjQPPFZVyTEXpc+y8ccicJZDLc4RHSde4tr7sT1DvCVtL6F2tN1SAtxZ7mGyoFdkQncpGHjDDtmQSzwQGSdF7iUvO0HGlgZPNGqmJCEsbkhKXmAmmS+N+G36Q8+TDCnjZSloSerFV0XXcjOYuNG9DBlUBMt7O9Zxi5jHga/xw== 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=dV0ZY0FenLXeEWER/+oEQgXObGUTdxJ8AzO6ezD5LKE=; b=av9uzMduuVGaAEHXq8aMHelsb7pMO6VOlSAzFjm7/LjsFAHkS7KQwP2b2moMZptnz1/QdCONsfC3PMT3MIEnXA86oh0cmBPlF0R1gZYMt7m8oqKaReizhRhzp0pzAWG8vQwHEP0tRACqbU3zHHyU9v7Vugx5R28f/ZvXGYXxN0u/Bg4GcjUrRwAUp8bJjfDnSXOfzKB6C82LOJs7QNqxUrkwcZz/IP/mwU/T2dEooJfsUFKU1U0CSai/G1e8GVz7tEUxPAsAgPqV8XBlUFHR3amipAc4QBFwzKve7r+vJtXE0HxdDPIYKepgoCvCO/KGQMflhW9vUPshLKHZqx1atg== 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=dV0ZY0FenLXeEWER/+oEQgXObGUTdxJ8AzO6ezD5LKE=; b=h0qxTdG/0gyDmW6Uie+5vDjstKWTdfHv3KD5YRxC98CTUvWA4fRsPrz+YUzo/Hz9GWuYecN78yq7RKKQ1uIbAWBKIR0r8hdYAi3Jf8WGBBHolPmn0wtGOE/VrBopTggPrkZfXNAb0JybctXtzTBXiTOEuf+PwI3OavqykKDAet4= 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 CY4PR1101MB2312.namprd11.prod.outlook.com (2603:10b6:910:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.30; Wed, 31 Mar 2021 12:18:58 +0000 Received: from CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::6dcc:f099:6ba8:6ebe]) by CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::6dcc:f099:6ba8:6ebe%10]) with mapi id 15.20.3977.035; Wed, 31 Mar 2021 12:18:58 +0000 From: Raoul Strackx Subject: [PATCH 2/3] x86/sgx: Fix compatibility issue with OPENSSL < 1.1.0 To: linux-sgx@vger.kernel.org Autocrypt: addr=raoul.strackx@fortanix.com; keydata= LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgptUUlOQkYyb2lmOEJFQURN UkFMT1ZjRkYyTlQva1FsWTBtVnN3YlMrYi9WNzR1azZFcDdxenpoNHpHbEtSS1pzClplS0I4 WmpFT2h5Q2pZaExwdnJHTVh2cTV1bm5pWENIbG9BR1hZRm9rN0Q0SGd2Q0djYnlTYVRMQjds NHc4MFIKOStYUkp2SnJpMEdPSmVubjRnNUpIQU5RN2h5YWl5RlRIYTVERU5CMjc2VG9kZUFQ bnVidGl1VmRDT0lnQVJVbAp1dzJHemFsbmY0WmZ1TGdEaHg5YzIza2pjZTFBQkFWbWdxUEtN TkVUSnhyZFdLQUt5QkVIWGJ0Snh6YnR4bFI1CnFUZU8yTExCU2V4TFBDbTRZOTZzRHlGK3JJ a2FpRk5JQWk2b3RrTFBxYkROUlB4OTdLTTkzcmh5dVpIaWVQM1gKNWY5dG8vN0xEcGhqV0ds L0ZBcldmT2U1QTgxTnhoTG5GNm9kakMrN2JwakdkNXdvM2E5TTkya2wyelJ1bEhSUAoreFFY T2Z4NkNoNnBMSVkvbmRtSGZOVDA2ZTBCUkt1MlZxWEw4Y2Y1a2pkMW4waW1vU0FxOElGNmFq UThBdHl0CkR1T3JpTk82WGFQRVlqaHVvTzF5YnBFeDJCWE95N3J4aUN5WFlkSldJVmY3T29a c0xEM0wzTHBYM2Q4K1hZYXUKeWxab2dVaFErMHpoWlhBVnExSEkzc2duNnFIZ2RTT0J6aUJI cnhycGFvU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xSHRWM1Z5UTNxN0N1UTlCTTdnQzVpK1JleQpHSU14Zm0v a09GWTRLRUxOeVYrV01PK2lXRHpZS21tTUxnUkVXNitqZk5jMzhrYWhaQjI2RmJOZTh6QmxU cVpPCmhxYmNZR1ZZNW9Ec004YSthbkwyZDhmaStnPT0KPW9ZT0QKLS0tLS1FTkQgUEdQIFBV QkxJQyBLRVkgQkxPQ0stLS0tLQo= Message-ID: <88588f0a-5aa8-9ea1-8e61-6d16530dbd4a@fortanix.com> Date: Wed, 31 Mar 2021 14:18:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Content-Language: en-US X-Originating-IP: [81.164.43.210] X-ClientProxiedBy: AM8P191CA0007.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::12) 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 AM8P191CA0007.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Wed, 31 Mar 2021 12:18:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d0a6599-15a4-4e7d-af5d-08d8f43f2893 X-MS-TrafficTypeDiagnostic: CY4PR1101MB2312: 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: T7ZRvYnpxa3aO3SI35T2IsXvwwS0A3CZbOzJaztqqtWT97XJcdkczhxqKIP/Qxk5/25gHLvA9bdr/o3EOW+8SJ6wnZT8GShyjGyrPDJiL7j60MTnDb4K+XoOZ0gfB79+S3YEXuFApRGD9SzvsNBZcUYMd3mTmEsGpksrWiyEtF/e8su4fAZJHeb3MNRByMeAT7pTDSmikfqFKbwocbmOI1D52h64unSMuzDfxxA9nST0gVFQBumPEH/Aco2l3Nagr86y0gT+M85nL4PUyz7l/hwQEQ9P/PQmYix699+Uyfk4rHghsOn5fMXJy69hJDNRxojc2QdaSLBCSEFeTcRqn59FghGxMKgzu4cFQISzOnoC8KYpJr2fU76MQvZTVaZ7zwMRo8MrH6+zAz8X6s3Buqpb9mYH/Kd10WGVBoV82ULLQS9/bkdAcAiBoVpVjSWm1tStSgrk2YROQ346yIKl9NwKiC1dxEIHHwTFHZUAZi9FAkVEHTtaITq+2k5XK2dw2QI2CJNGeGEOAuLsiV8LZ0PyoRlZdgH5GHpU5jdwfcscIcSrkyF9AKjvPgFuMtS2dlRG22lUwU0a7cBX1VvvyQUMYbrH1Lr368Io9hf84a3tzJAqHLAell4N2ApwrKaZx3pwJc9B5coawCjE94336d4htbQUdqjfSy/E8t4F8l3s2H2tpbtTSTCTHNh4GJ2Sf6f+FmJWVc0+NW8MSVqbGvPi8EahkI7najCFjvxN2GQ= 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)(376002)(136003)(366004)(396003)(39840400004)(4744005)(66946007)(2906002)(52116002)(2616005)(6486002)(5660300002)(8936002)(8676002)(956004)(36756003)(316002)(44832011)(38100700001)(66556008)(66476007)(6916009)(83380400001)(86362001)(6666004)(16576012)(186003)(26005)(478600001)(16526019)(31686004)(31696002)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?nMXTSRXqMcQ2kOKltraQvcc/rsgOyO?= =?utf-8?q?Vek9Gemh0Ph349/YILPe5eQgOHyRWZVBEpj31c5ii8CXVxTulFA6IF8nk77rM46Y3?= =?utf-8?q?nAuyDo/dbXdo5MV1Xxm9tLL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PspChEm61TjvXTOY0xek5mwpPu/X?= =?utf-8?q?TJLmDiloQUvOINTyqT0zyEHN/lkMcoHOAS9U+L+t1rM6nxscAOz0jG+XORsH6mnAZ?= =?utf-8?q?DBjM9b9nx3o6igGDdqn5TPYGbgq9DRfQB2nDZpeC6126c3KiULVEqMfgiDatc1/eY?= =?utf-8?q?Evhz9d3yYh5BOT4ubB5wuY6VzME7kwAFvXDfA+n8OUgqmKgqwxjfJCTVJOfiFCzWR?= =?utf-8?q?DVBRboFI7H/xTAKbNvupJIG8es05ksCnH6mn92TF/G2e0xLk9sr7mN5Hs5ozsuUTu?= =?utf-8?q?qZftak2mGciMBY?= X-OriginatorOrg: fortanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d0a6599-15a4-4e7d-af5d-08d8f43f2893 X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1783.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2021 12:18:57.4739 (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: cCGTB2rlSFK05UxBze5RE8z0QN/QTHLOPsasDX4+6twCghDJiGlhj6vttMDa1+xnMboGXkNh1NFzqb+OkAK/KxFWAC/MWtiKfP2SRwJNPZM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2312 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 Wed Mar 31 12:18:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raoul Strackx X-Patchwork-Id: 12175369 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 CF16EC433E0 for ; Wed, 31 Mar 2021 12:20:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 970EB61957 for ; Wed, 31 Mar 2021 12:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235450AbhCaMTh (ORCPT ); Wed, 31 Mar 2021 08:19:37 -0400 Received: from mail-mw2nam08on2110.outbound.protection.outlook.com ([40.107.101.110]:19361 "EHLO NAM04-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235457AbhCaMTS (ORCPT ); Wed, 31 Mar 2021 08:19:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L6fRqXfE12vX8LSEsPig5IrGZLVo9aHiW6imRstfQPXio8idB8hzNXcSaVUAp8Jc5LwRROOUbVAXlAK3395C/kqQC/6dQh/6MZ/f+Abwp56qNEIB4HqiaExovuI/eQqLNkU5WQSbDoyTPvhYT57hXR3+UPzLCP0gsJrCsUnD6kMjicI6HCabwcGCOCdMtfBy1xyTWHMRXINyk5TrzcUzC2uc2C3uRk/COD/VDFE6XAnrW69+q1iVgNZwn7deVUqeUfFry9uZOZY3LeAo0QftEJKrC6jnYuB9InRzb7YfimH96Vci7KQjZkl/HV/1orC5x2U7fA0pthDqUNjYyq3p/w== 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=sn0/WsafaTrgS1iuYWiKLeoO90R7Il7zyL18dwiDe8Y=; b=P4hp1yCVPDwxo0BOap3ha63irSDXyjfrr3Pm4BQqk/rIxokGJULv4GqA83C6/Y+E3fbREdyp83noCMZ22WrN1vjyMJcrEG/XoXgyMmyU39gjMWxAKk5F30+iQE1NA5BtGRvZLl67WCX+D6wYVJNXAnvCiXYBUQgUAn6rKiIsDlbCttFg904hkXGkQjKEBMDk6HNncmjH9waQ9rYr7F7cMB8ForuXTP32gkpb7ddJkCbMq4E4DOyW/rTYvFmoihOPqgr3cOoTv0zzMcEVFVg7OGi0KA6vHwqcyHKZ4TrpLX6Z+Mfs8C4xroahf5HnUrQDWjVu/F9VfLhQMocF+o5uBQ== 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=sn0/WsafaTrgS1iuYWiKLeoO90R7Il7zyL18dwiDe8Y=; b=ioDFpd1IMyJA4WuuekLY890B3JUa4dkO9NBZ//7hLUOxdmxJ1NSXolVvj9q/MlocDrBoYCfCxREKNYNEPgJlAUPbZhKxQLUdBs8yssQUt15mP/mD3Xp2DAq0HXs1cVxL0XDybeyQzvM+UAYTvY8Yg3hVoPwx0HCTSP516jIOOQo= 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 CY4PR1101MB2312.namprd11.prod.outlook.com (2603:10b6:910:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.30; Wed, 31 Mar 2021 12:19:00 +0000 Received: from CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::6dcc:f099:6ba8:6ebe]) by CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::6dcc:f099:6ba8:6ebe%10]) with mapi id 15.20.3977.035; Wed, 31 Mar 2021 12:19:00 +0000 From: Raoul Strackx Subject: [PATCH 3/3] x86/sgx: eextend ioctl selftest To: linux-sgx@vger.kernel.org Autocrypt: addr=raoul.strackx@fortanix.com; keydata= LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgptUUlOQkYyb2lmOEJFQURN UkFMT1ZjRkYyTlQva1FsWTBtVnN3YlMrYi9WNzR1azZFcDdxenpoNHpHbEtSS1pzClplS0I4 WmpFT2h5Q2pZaExwdnJHTVh2cTV1bm5pWENIbG9BR1hZRm9rN0Q0SGd2Q0djYnlTYVRMQjds NHc4MFIKOStYUkp2SnJpMEdPSmVubjRnNUpIQU5RN2h5YWl5RlRIYTVERU5CMjc2VG9kZUFQ bnVidGl1VmRDT0lnQVJVbAp1dzJHemFsbmY0WmZ1TGdEaHg5YzIza2pjZTFBQkFW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TF4YVVkZG9qdk53T1RKRVcvb3Jhd2tuUUF1ZW5EYnpBR1Z1CkdMV0w3T2ov RGZyTFBBemNXV25GblV2VVc2NEFEWFNBOTh0SWNBY3lod05uY2lqYnNIUkFTQlJidkg5RFhJ c2wKaEwxMDArdzZNTWNMeFpNVmJ4UHBTWWVHaGp4SjdNUysyeGp3eDB4MWlMNmszZk5UNHNT Q3dZa0xRZjJlKzhxYwpFYjNTa0Q0VFR3RDQxUW85SFNuUlkwdnRqblNyZkwyQ3JhVmptOXhh MXhmNlJDQ3kvaXpKNU5TQTZZMXduT0U3Ck1IOHorcVFUM1NxMld0a0NzU1M5K1U2VU9OWmFK dFN5MWNvZ1ZhMDV1QWdRY0tHT3FvcHg3QWlmZUhIUFpqZnIKakVNaHJZQ3Q5WXgzR1VET0hs MnRObDJIOStqZC9BVjByMDRKUTNxSHRWM1Z5UTNxN0N1UTlCTTdnQzVpK1JleQpHSU14Zm0v a09GWTRLRUxOeVYrV01PK2lXRHpZS21tTUxnUkVXNitqZk5jMzhrYWhaQjI2RmJOZTh6QmxU cVpPCmhxYmNZR1ZZNW9Ec004YSthbkwyZDhmaStnPT0KPW9ZT0QKLS0tLS1FTkQgUEdQIFBV QkxJQyBLRVkgQkxPQ0stLS0tLQo= Message-ID: <6cae4ec0-899a-5ae2-353a-d5877296aa72@fortanix.com> Date: Wed, 31 Mar 2021 14:18:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Content-Language: en-US X-Originating-IP: [81.164.43.210] X-ClientProxiedBy: AM8P191CA0019.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::24) 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 AM8P191CA0019.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Wed, 31 Mar 2021 12:19:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d0e3ed4b-9d03-4dec-d6dc-08d8f43f2a7a X-MS-TrafficTypeDiagnostic: CY4PR1101MB2312: 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: qNGO9I/sKBtSDyVQGcP6M1Nfi0iG3kapiXZ8+KDW0TJuXeD9ee0+8SSb1PmeRyMC/RutzgyJnz1eBkuY046dqA8A0XsdwCpE/ki5JrF87rxgexHGIJTgapTWDFeDRMGLF50U22sHJifxjHmCGgwa9wJ/Xej7wXbXiWJ5tp9YALIXlWI4dMu4EWMHkUbRkWrvV3ZqStMkKXTfOP88M+p7KUsCgQUC0XC0TtXzfLm7vgIlOE/T8wxBKr3A2RIJ3Zo3SOs1cNWfzDAuFSXXEu1F2j/j9DrKd7bcFDZl53oDkLpymWYzLx/ujcF1uecB05aBJm13Jfc+C53e5m7+8RH87upgJSYOxWrULS6POYJ/BOOUkHVf/+4f8d/KhPE4DobUgXYyCsNuAUC+PVQgzymVCcJF95DEa1o5YOaLdmgLAUyPnbJa1xxAL1mBs3aqlsyoiGVaTkATM4AvIdcS0DplZhwcKQ6+bJP9sMfcfhelIw/u5NL/+36pdljpeA5Ar0hbgexwlqmgSWP0n1egIb1Dk4welETo+Rtsbub7zm6CkUIOsGrye8WPf6xvlQrPRj0exc9hk20PeoW00mOtX1PZncIqYqtfGoHO9CT/rrJ0NNlPN/b7vDgmzjUIlyP3+j1gdwB5ak7AhKwzNvkvJe6wrboONMkLTbW2lRCfSwrOpHzsobv2XfkxND6LAQ068whSdmblk6SZMIZM95ASvjy0dVgyKZv154/RgtpNcKx4NYs= 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)(376002)(136003)(366004)(396003)(39840400004)(66946007)(2906002)(52116002)(2616005)(6486002)(5660300002)(8936002)(8676002)(956004)(36756003)(316002)(44832011)(38100700001)(66556008)(66476007)(6916009)(83380400001)(86362001)(6666004)(16576012)(186003)(26005)(478600001)(16526019)(31686004)(31696002)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?t/OgIj1mTb+bBUU3KZWiWoD8Lut7PM?= =?utf-8?q?F34prbNa7pLT8LwxgYk56+6XQC4s97uO/JOlJkDWXvr92knuvCqJfJQynk1h5MRoi?= =?utf-8?q?RLFu3SrGfgjLRet8FuyYpuSdMpxIvjLf46VZ13PXULhgG+9IbckZLQEztLxszBDcw?= =?utf-8?q?TNBkyLPsCcHh6uwKrDWw6eWCPrWT1GdY31fbXTY8litE//tIqduTh1i1C/2+t7zq+?= =?utf-8?q?v9BM/OXsOiAfb/P7WcelMWe3wyhlFNBT/yM+DChykjm5wdVXhuhNdCJT4kabwqXda?= =?utf-8?q?rqXHtUh6WAT8Dk2hKfIGtcOZmP2YQCVsjN+QFW8oyPcHjm1gEewUSbUxCj69j4CQH?= =?utf-8?q?wEf/AqlLV+5Z/NjlesqEBk57u4QMv+NDd4VuAr7zV24YWOtuAa8EIYJ94ODDWtQv4?= =?utf-8?q?IaiulsjAoRRT+JOzgJtg28KrehhRKjtoZimnsLtFr04m06+F6latROdy/L7D6Pm1I?= =?utf-8?q?V8VZ9B1Nrf8JO7jT5eWuM0lIqRtj5/TCLdy+UZ1vh7E8/Zguv22GI7SsQF1ZCW6an?= =?utf-8?q?ov/1Ze3OJLHN57HtwFbbS0RL+2gOiPvdePWEAVljiy7NDQGw8uC+Eg3lWXaIGyn3g?= =?utf-8?q?EU/HfYBlopIa5QX7iABdv2ru8x9hH9Hd2SHD+aOimDdlgFk72S6tyiYRu99JwZK2Z?= =?utf-8?q?5UfPaw4WbaeY9nyZk+Viii3CqODuHEAA5CEt7VqcFBTrFIrnwPaJ3ivuNEp8myGXh?= =?utf-8?q?AsQUUKaYKpcOGjN+2EtNHZGVdi5yETHIDjCZR3JihD9DSHQodJpk5U5AEasxCCtPZ?= =?utf-8?q?becN4KBDZ85XMiWSiHD5HWfmlBBzK2qrZnDYHbdVQb1kDro9+YSniG7rAFdA/qzah?= =?utf-8?q?Y31dFv8ST+KHs2sUVGi/zHbqzzIanastw+Yxvi7HiAh1esYFd8A7h+FfznSzbO1G8?= =?utf-8?q?X+EUyrJ85VNNKCiLGbL6i3FVnLn8aPaYmOEnAIdV4JqPDy20L/vIgfSb1ZxwgJQ4T?= =?utf-8?q?k8IjZs88hy3VCPhLzvsz0Fd6kjd8/uXXMip+Tgyr4MPCrzDoG5QbvZtNsCeRk04gX?= =?utf-8?q?0cGvTUYx83eEj597q341KgiGN9vM3GdgEpLY8upYd0F3Yg6ZTFvRTUMGILrvESuEu?= =?utf-8?q?eicqJvw/PenHW4C/ymhAGfmyVfvueiNJSDtHp7ZOUcz0UJyjzyDUENBiE0FVCHHQ1?= =?utf-8?q?ALgk9s0o9mQ1vrhk/KsC83ni8sJ5p8phJFu2MfNuymrAw7Oh1/kFqMe1uAeQV80ID?= =?utf-8?q?T0qJCcWR7WzKgdCIYlblSnZ+PlbrUr19r/bFNMk9tQWYTnY6/ms/ohPgG4dYyqfhG?= =?utf-8?q?SpW2qEZWu1sBs9?= X-OriginatorOrg: fortanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0e3ed4b-9d03-4dec-d6dc-08d8f43f2a7a X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1783.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2021 12:19:00.8004 (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: jcD46PPP/w/i54i1vn8IIzUEiMo9/zo6aTv9Q7WwXRxHAoe/k6qTApIBL11fstjuwS1H2QZ1N4PVW7/A5cUE1utq+OWQuxojbZWPXEhoq30= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2312 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 | 55 ++++++++++++++++++++++++++++----- tools/testing/selftests/sgx/main.h | 1 + tools/testing/selftests/sgx/sigstruct.c | 38 +++++++++++------------ 4 files changed, 67 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..52f0569 100644 --- a/tools/testing/selftests/sgx/load.c +++ b/tools/testing/selftests/sgx/load.c @@ -102,28 +102,67 @@ 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 (0 < ioc.length) { + 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 +236,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 +248,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;