[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrUsj1YBwcEDiyU-seTiCuyFJW+BvunzOUUiUYQj+ojpEg@mail.gmail.com>
Date: Thu, 10 Jan 2019 16:30:06 -0800
From: Andy Lutomirski <luto@...nel.org>
To: Sean Christopherson <sean.j.christopherson@...el.com>
Cc: Andy Lutomirski <luto@...nel.org>,
"Huang, Kai" <kai.huang@...el.com>,
Jethro Beekman <jethro@...tanix.com>,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
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>,
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 Thu, Jan 10, 2019 at 3:54 PM Sean Christopherson
<sean.j.christopherson@...el.com> wrote:
>
> On Thu, Jan 10, 2019 at 01:34:44PM -0800, Andy Lutomirski wrote:
> > >> On Jan 9, 2019, at 8:31 AM, Sean Christopherson <sean.j.christopherson@...el.com> wrote:
> > >>
> > >> On Tue, Jan 08, 2019 at 02:54:11PM -0800, Andy Lutomirski wrote:
> > >
> > >> I do think it makes sense to have QEMU delegate the various ENCLS
> > >> operations (especially EINIT) to the regular SGX interface, which will
> > >> mean that VM guests will have exactly the same access controls applied
> > >> as regular user programs, which is probably what we want.
> > >
> > > To what end? Except for EINIT, none of the ENCLS leafs are interesting
> > > from a permissions perspective. Trapping and re-executing ENCLS leafs
> > > is painful, e.g. most leafs have multiple virtual addresses that need to
> > > be translated. And routing everything through the regular interface
> > > would make SGX even slower than it already is, e.g. every ENCLS would
> > > take an additional ~900 cycles just to handle the VM-Exit, and that's
> > > not accounting for any additional overhead in the SGX code, e.g. using
> > > the regular interface would mean superfluous locks, etc...
> >
> > Trapping EINIT is what I have in mind.
>
> Phew, had me worried :-)
>
> > >
> > > Couldn't we require the same privilege/capability for VMs and and EINIT
> > > tokens? I.e. /dev/sgx/virtualmachine can only be opened by a user that
> > > can also generate tokens.
> >
> > Hmm, maybe. Or we can use Jarkko’s securityfs attribute thingy.
> >
> > Concretely, I think there are two things we care about:
> >
> > First, if the host enforces some policy as to which enclaves can
> > launch, then it should apply the same policy to guests — otherwise KVM
> > lets programs do an end run around the policy. So, in the initial
> > incarnation of this, QEMU should probably have to open the provision
> > attribute fd if it wants its guest to be able to EINIT a provisioning
> > enclave. When someone inevitably adds an EINIT LSM hook, the KVM
> > interface should also call it.
>
> Sort of. A guest that is running under KVM (i.e. VMX) is much more
> contained than a random userspace program. A rogue enclave in a VMX
> guest can attack the guest kernel/OS, but barring a bug (or more likely,
> several major bugs) elsewhere in the virtualization stack the enclave
> can't do anything nasty to the host. An enclave would let someone hide
> code, but enclaves are even more restricted than cpl3, i.e. there's not
> a lot it can do without coordinating with unencrypted code in the guest.
>
> And if someone has sufficient permissions to run a KVM guest, they're
> much more likely to do something malcious in the guest kernel, not an
> enclave.
Are you sure? On my laptop, /dev/kvm is 0666, and that's the distro
default. I don't think this is at all unusual. I'm not particularly
concerned about a guest attacking itself, but it's conceptually
straightforward to bypass whatever restrictions the host has by simply
opening /dev/kvm and sticking your enclave in a VM.
>
> All that aside, I don't see any justification for singling out SGX for
> extra scrutiny, there are other ways for a user with KVM permissions to
> hide malicious code in guest (and at cpl0!), e.g. AMD's SEV{-ES}.
I'm not singling out SGX. I'm just saying that the KVM should not
magically bypass host policy. If you want to assign a virtual
function on your NIC to a KVM guest, you need to give your QEMU
process that privilege. Similarly, if someone has a MAC policy that
controls which processes can launch which enclaves and they want to
run Windows with full SGX support in a VM guest, then they should
authorize that in their MAC policy by giving QEMU unrestricted launch
privileges.
Similarly, if access to a persistent provisioning identifier is
restricted, access to /dev/kvm shouldn't magically bypass it. Just
give the QEMU process the relevant privileges.
Powered by blists - more mailing lists