Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4663820ybi; Mon, 3 Jun 2019 15:05:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQu3bG9zOAXE52ak/ORCMh36Q7xro8ydg8n5795C6rOZ+qFHn5r3RJsxILeGJ8NPGIFiDw X-Received: by 2002:aa7:804c:: with SMTP id y12mr33537563pfm.94.1559599520284; Mon, 03 Jun 2019 15:05:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559599520; cv=none; d=google.com; s=arc-20160816; b=lH49AZoILMFqT+1/ZIs371mwqGq+I7Z8SfPD7MiZphdc5sW9j32P4eg3qAbuaEUw4b /aVwt2OozPJmsgQv94NNmwUwPcZRWid4F9KAHLBKJe+j8QNpY4PZ9UJwjJatGzUCHb2a 26y2atfzJCQpycCcySFvpdQ0CmZxhLWgWhcKCaeaUegtuFESDQrqHasRorUJOwnhPbhg 0MU2VnhnIeH4mpK3eKRrMi9vV+L940uZKFC7zA2Qhu2lVqwfqVJijBqzeJ3rxzA6nRF4 u5OFR0NWm9u69G5HmEtgz4hRqPegZpXc8T48sANZpQGfiyGIZaaJOhcnGgRd3tRtVuGF vapg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=aedh8sDMN8NPMk6Q7cxLfztGZbsUF3hm8E0L66PAZNY=; b=DkkDLfXd8VbtjKazaIjxzgBPkHOHwZW+dsW75xCQxf+qyeKS+JTymmT5vwCNJOgK8u VcvACNfWCkegYS1LUEaCj/38L3tuDbTeC3hB9M3Kd7RPtTm/9aeChnxnDFh95ceupsJg khqlXV3vGtjPypZyEKGYo71/qZ/Hyir+bFDimSFj6SxK5ioQ2coP3YToBDUECahhVFCO AOc946V1Z4UHLYZ6lOrpdmI4zNHb4CwxcxkVHWz7aSEdoI7bkmijndPu5/T/weaJiVYm 3z/UaXMhn7iZ9oz9XUuW4/Iv0loLw7TMxfIAmu71/WEfhv9Potbx4H3z9B5MPc6N3L+R 89CA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z195si18137189pgz.493.2019.06.03.15.05.03; Mon, 03 Jun 2019 15:05:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726531AbfFCWCW (ORCPT + 99 others); Mon, 3 Jun 2019 18:02:22 -0400 Received: from mga01.intel.com ([192.55.52.88]:22918 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbfFCWCW (ORCPT ); Mon, 3 Jun 2019 18:02:22 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 13:39:50 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by orsmga002.jf.intel.com with ESMTP; 03 Jun 2019 13:39:50 -0700 Date: Mon, 3 Jun 2019 13:39:50 -0700 From: Sean Christopherson To: "Xing, Cedric" Cc: Jarkko Sakkinen , Andy Lutomirski , Stephen Smalley , James Morris , "Serge E . Hallyn" , LSM List , Paul Moore , Eric Paris , "selinux@vger.kernel.org" , Jethro Beekman , "Hansen, Dave" , Thomas Gleixner , Linus Torvalds , LKML , X86 ML , "linux-sgx@vger.kernel.org" , Andrew Morton , "nhorman@redhat.com" , "npmccallum@redhat.com" , "Ayoun, Serge" , "Katz-zamir, Shay" , "Huang, Haitao" , Andy Shevchenko , "Svahn, Kai" , Borislav Petkov , Josh Triplett , "Huang, Kai" , David Rientjes , "Roberts, William C" , "Tricca, Philip B" Subject: Re: [RFC PATCH 3/9] x86/sgx: Allow userspace to add multiple pages in single ioctl() Message-ID: <20190603203950.GJ13384@linux.intel.com> References: <20190531233159.30992-1-sean.j.christopherson@intel.com> <20190531233159.30992-4-sean.j.christopherson@intel.com> <960B34DE67B9E140824F1DCDEC400C0F654ECBBD@ORSMSX116.amr.corp.intel.com> <20190603200804.GG13384@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190603200804.GG13384@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 03, 2019 at 01:08:04PM -0700, Sean Christopherson wrote: > On Sun, Jun 02, 2019 at 11:26:09PM -0700, Xing, Cedric wrote: > > > From: Christopherson, Sean J > > > Sent: Friday, May 31, 2019 4:32 PM > > > > > > +/** > > > + * sgx_ioc_enclave_add_pages - handler for %SGX_IOC_ENCLAVE_ADD_PAGES > > > + * > > > + * @filep: open file to /dev/sgx > > > + * @cmd: the command value > > > + * @arg: pointer to an &sgx_enclave_add_page instance > > > + * > > > + * Add a range of pages to an uninitialized enclave (EADD), and > > > +optionally > > > + * extend the enclave's measurement with the contents of the page (EEXTEND). > > > + * The range of pages must be virtually contiguous. The SECINFO and > > > + * measurement maskare applied to all pages, i.e. pages with different > > > + * properties must be added in separate calls. > > > + * > > > + * EADD and EEXTEND are done asynchronously via worker threads. A > > > +successful > > > + * sgx_ioc_enclave_add_page() only indicates the pages have been added > > > +to the > > > + * work queue, it does not guarantee adding the pages to the enclave > > > +will > > > + * succeed. > > > + * > > > + * Return: > > > + * 0 on success, > > > + * -errno otherwise > > > + */ > > > +static long sgx_ioc_enclave_add_pages(struct file *filep, unsigned int cmd, > > > + unsigned long arg) > > > +{ > > > + struct sgx_enclave_add_pages *addp = (void *)arg; > > > + struct sgx_encl *encl = filep->private_data; > > > + struct sgx_secinfo secinfo; > > > + unsigned int i; > > > + int ret; > > > + > > > + if (copy_from_user(&secinfo, (void __user *)addp->secinfo, > > > + sizeof(secinfo))) > > > + return -EFAULT; > > > + > > > + for (i = 0, ret = 0; i < addp->nr_pages && !ret; i++) { > > > + if (signal_pending(current)) > > > + return -ERESTARTSYS; > > > > If interrupted, how would user mode code know how many pages have been EADD'ed? > > Hmm, updating nr_pages would be fairly simple and shouldn't confuse > userspace, e.g. as opposed to overloading the return value. Or maybe update @addr and @src as well? That would allow userspace to re-invoke the ioctl() without having to modify the struct.