lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181219144515.GA30909@linux.intel.com>
Date:   Wed, 19 Dec 2018 06:45:15 -0800
From:   Sean Christopherson <sean.j.christopherson@...el.com>
To:     Jethro Beekman <jethro@...tanix.com>
Cc:     Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
        Andy Lutomirski <luto@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "x86@...nel.org" <x86@...nel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Peter Zijlstra <peterz@...radead.org>,
        "H. Peter Anvin" <hpa@...or.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-sgx@...r.kernel.org" <linux-sgx@...r.kernel.org>,
        Andy Lutomirski <luto@...capital.net>,
        Josh Triplett <josh@...htriplett.org>,
        Haitao Huang <haitao.huang@...ux.intel.com>,
        "Dr . Greg Wettstein" <greg@...ellic.com>
Subject: Re: x86/sgx: uapi change proposal

On Wed, Dec 19, 2018 at 09:36:16AM +0000, Jethro Beekman wrote:
> On 2018-12-19 14:41, Jarkko Sakkinen wrote:
> >On Wed, Dec 19, 2018 at 08:41:12AM +0000, Jethro Beekman wrote:
> >>One weird thing is the departure from the normal mmap behavior that the
> >>memory mapping persists even if the original fd is closed. (See man mmap:
> >>"closing the file descriptor does not unmap the region.")

It won't (be a departure).  mmap() on a file grabs a reference to the
file, i.e. each VMA keeps a reference to the file.  Closing the original
enclave fd will only put its reference to the file/enclave, not destroy
it outright.

> >
> >The mmapped region and enclave would be completely disjoint to start
> >with. The enclave driver code would assume that an enclave VMA exists
> >when it maps enclave address space to a process.
> >
> >I.e. VMA would no longer reference to the enclave or vice versa but
> >you would still create an enclave VMA with mmap().
> >
> >This is IMHO very clear and well-defined semantics.
> >
> >>>struct sgx_enclave_add_page {
> >>>	__u64	enclave_fd;
> >>>	__u64	src;
> >>>	__u64	secinfo;
> >>>	__u16	mrmask;
> >>>} __attribute__((__packed__));
> >>
> >>Wouldn't you just pass enclave_fd as the ioctl fd parameter?
> >
> >I'm still planning to keep the API in the device fd and use enclave_fd
> >as handle to the enclave address space. I don't see any obvious reason
> >to change that behavior.
> >
> >And if we ever add any "global" ioctls, then we would have to define
> >APIs to both fd's, which would become a mess.
> >
> >>How to specify the address of the page that is being added?
> >
> >Yes, that is correct and my bad to remove it (just quickly drafted what
> >I had in mind).
> 
> So your plan is that to call EADD, userspace has to pass the device fd AND
> the enclave fd AND the enclave address? That seems a little superfluous.

I agree with Jethro, passing the enclave_fd as a param is obnoxious.
And it means the user needs to open /dev/sgx to do anything with an
enclave fd, e.g. the enclave fd might be passed to a builder thread,
it shouldn't also need the device fd.

E.g.:

	sgx_fd = open("/dev/sgx", O_RDWR);
	BUG_ON(sgx_fd < 0);

	enclave_fd = ioctl(sgx_fd, SGX_ENCLAVE_CREATE, &ecreate);
	BUG_ON(enclave_fd < 0);

	ret = ioctl(enclave_fd, SGX_ENCLAVE_ADD_PAGE, &eadd);
	BUG_ON(ret);

	...

	ret = ioctl(enclave_fd, SGX_ENCLAVE_INIT, &einit);
	BUG_ON(ret);

	...

	close(enclave_fd);
	close(sgx_fd);


Take a look at virt/kvm/kvm_main.c to see how KVM manages anon inodes
and ioctls for VMs and vCPUs.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ