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;