All of lore.kernel.org
 help / color / mirror / Atom feed
From: Topi Miettinen <toiwoton@gmail.com>
To: Jethro Beekman <jethro@fortanix.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Casey Schaufler <casey@schaufler-ca.com>,
	Andy Lutomirski <luto@kernel.org>,
	casey.schaufler@intel.com,
	Sean Christopherson <sean.j.christopherson@intel.com>,
	linux-sgx@vger.kernel.org, "Svahn, Kai" <kai.svahn@intel.com>,
	"Schlobohm, Bruce" <bruce.schlobohm@intel.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	Haitao Huang <haitao.huang@linux.intel.com>,
	ben@decadent.org.uk
Subject: Re: [PATCH 2/4] x86/sgx: Put enclaves into anonymous files
Date: Sat, 4 Apr 2020 10:27:53 +0300	[thread overview]
Message-ID: <ea7471ff-146a-73af-903d-34552614b302@gmail.com> (raw)
In-Reply-To: <454e7252-8827-510d-65f0-f2ca60208e27@fortanix.com>

On 4.4.2020 8.46, Jethro Beekman wrote:
> This appears to originate in Debian
> 
> Rationale: https://salsa.debian.org/kernel-team/initramfs-tools/-/merge_requests/9
> 
> Interestingly, they claim mmap(/dev/zero) is special-cased? Can we do the same for SGX?
> 
> Some allowances were made in https://salsa.debian.org/kernel-team/initramfs-tools/-/commit/d6c6eeca3540d18f5bce95b5ffcb1823ab3050ea
> 
> Including those people in this conversation.
> 
> Ben, Towi: for context, see https://lore.kernel.org/linux-sgx/20200319142434.GA11305@linux.intel.com/T/ and https://lore.kernel.org/linux-sgx/20200401084511.GE17325@linux.intel.com/T/
> 
> --
> Jethro Beekman | Fortanix
> 
> On 2020-04-04 05:54, Andy Lutomirski wrote:
>>
>>
>>> On Apr 3, 2020, at 3:08 PM, Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote:
>>>
>>> On Fri, Apr 03, 2020 at 08:50:08AM -0700, Casey Schaufler wrote:
>>>>> How does smackfs interact with namespaces?
>>>>
>>>> Smack attributes are global. Aside from privilege issues, namespaces
>>>> ignore and are ignored by Smack.
>>>
>>> Okay.
>>>
>>> For SGX, I foresee things as:
>>>
>>> 1. Existing files are global.
>>> 2. If a policy of any kind is ever added it needs to be *per container*.
>>>    I'm not sure whether PID or user namespace is the right choice here,
>>>    but does not matter right now as the feature is not in the queue.
>>>
>>> To summarize:
>>>
>>> 1. We have a heterogeneous set of files (i.e. 'enclave' and 'provision'
>>>    are not "different sames").
>>> 2. The files probably will have heterogeneous visibility requirements.
>>>
>>> I think based on these premises own file system would be a more decent
>>> choice than populating /dev. Beside, SGX hasn't been a driver for a
>>> while.
>>>
>>> Andy, what do you think of this?
>>
>> Probably okay.  There are two semantic questions you’ll have to address, though:
>>
>> - What happens if you mount sgxfs twice?  Do you get two copies that can diverge from each other, or do you get two views of the same thing?
>>
>> - Can it be instantiated from outside the root initns?
>>
>> It’s certainly conceptually simpler to stick with device nodes. Why exactly is Ubuntu noexecing /dev?
>>
>>>
>>> /Jarkko
> 

My goal is to block executing binaries directly from /dev and using the 
file descriptors from device files to avoid EXECMEM, without relying on 
MACs. If the SGX device can be used to make new executable mappings, it 
should honor noexec for /dev. Then initramfs should make a similar 
exception as with v86d and grant exec to /dev. I think sgxfs should also 
honor noexec but it probably does not make sense to mount it so.

With an ioctl to SGX device the caller can change previously writable 
memory to executable. It should be able to trigger PROCESS__EXECMEM 
check for SELinux, so perhaps LSM hook for mprotect should be called:
https://github.com/intel/linux-sgx-driver/blob/95eaa6f6693cd86c35e10a22b4f8e483373c987c/sgx_ioctl.c#L254

Also SELinux reference policy doesn't know yet about SGX. Can the SGX 
enclave access physical memory, kernel memory or bypass MMU somehow even 
for the thread? If it can bypass SELinux protections, access should be 
conditional to boolean allow_raw_memory_access.

-Topi

  reply	other threads:[~2020-04-04  7:28 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 11:44 [PATCH 0/4] Migrate enclave mapping to an anonymous inode Jarkko Sakkinen
2020-03-31 11:44 ` [PATCH 1/4] x86/sgx: Remove PROT_NONE branch from sgx_encl_may_map() Jarkko Sakkinen
2020-03-31 11:44 ` [PATCH 2/4] x86/sgx: Put enclaves into anonymous files Jarkko Sakkinen
2020-03-31 17:39   ` Andy Lutomirski
2020-04-01  0:24     ` Sean Christopherson
2020-04-02 21:41       ` Andy Lutomirski
2020-04-03  6:56         ` Jarkko Sakkinen
2020-04-03  6:59           ` Jarkko Sakkinen
2020-04-03 14:35           ` Casey Schaufler
2020-04-03 15:30             ` Jarkko Sakkinen
2020-04-03 15:50               ` Casey Schaufler
2020-04-03 22:08                 ` Jarkko Sakkinen
2020-04-04  3:54                   ` Andy Lutomirski
2020-04-04  5:46                     ` Jethro Beekman
2020-04-04  7:27                       ` Topi Miettinen [this message]
2020-04-04  9:20                         ` Jarkko Sakkinen
2020-04-06  6:42                         ` Jethro Beekman
2020-04-06 11:01                           ` Topi Miettinen
2020-04-06 16:44                             ` Andy Lutomirski
2020-04-06 17:17                               ` Jethro Beekman
2020-04-06 18:55                               ` Jarkko Sakkinen
2020-04-06 19:01                                 ` Jarkko Sakkinen
2020-04-06 19:53                                 ` Andy Lutomirski
2020-04-06 21:24                                   ` Jarkko Sakkinen
2020-04-06 23:18                                     ` Andy Lutomirski
2020-04-06 23:48                                       ` Jarkko Sakkinen
2020-04-07  7:15                                       ` Jethro Beekman
2020-04-07  8:48                                     ` Topi Miettinen
2020-04-07 16:52                                       ` Jarkko Sakkinen
2020-04-07  9:04                                     ` Topi Miettinen
2020-04-07 16:57                                       ` Jarkko Sakkinen
2020-04-07 16:59                                         ` Jarkko Sakkinen
2020-04-07 18:04                                           ` Jarkko Sakkinen
2020-04-07 19:54                                             ` Topi Miettinen
2020-04-08 13:40                                               ` Jarkko Sakkinen
2020-04-08 14:56                                                 ` Sean Christopherson
2020-04-09 18:39                                                   ` Jarkko Sakkinen
2020-04-08 21:15                                                 ` Topi Miettinen
2020-04-08 21:29                                                   ` Sean Christopherson
2020-11-19  7:23                                   ` Jethro Beekman
2020-11-19 16:09                                     ` Andy Lutomirski
2020-04-06 18:47                             ` Jarkko Sakkinen
2020-04-04  9:22                     ` Jarkko Sakkinen
2020-04-01  8:45     ` Jarkko Sakkinen
2020-03-31 11:44 ` [PATCH 3/4] x86/sgx: Move mmap() to the anonymous enclave file Jarkko Sakkinen
2020-03-31 11:44 ` [PATCH 4/4] x86/sgx: Hand over the enclave file to the user space Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea7471ff-146a-73af-903d-34552614b302@gmail.com \
    --to=toiwoton@gmail.com \
    --cc=ben@decadent.org.uk \
    --cc=bruce.schlobohm@intel.com \
    --cc=casey.schaufler@intel.com \
    --cc=casey@schaufler-ca.com \
    --cc=haitao.huang@linux.intel.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jethro@fortanix.com \
    --cc=kai.svahn@intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=sds@tycho.nsa.gov \
    --cc=sean.j.christopherson@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.