kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <jejb@linux.ibm.com>
To: Christophe de Dinechin <dinechin@redhat.com>
Cc: "Jörg Rödel" <jroedel@suse.de>,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Klaus Kiwi" <kkiwi@redhat.com>,
	linux-coco@lists.linux.dev, kvm@vger.kernel.org,
	amd-sev-snp@lists.suse.com
Subject: Re: [ANNOUNCEMENT] COCONUT Secure VM Service Module for SEV-SNP
Date: Sat, 06 May 2023 08:48:04 -0400	[thread overview]
Message-ID: <2f1c0527ab42dee7d4eaf562c6a14851bb64c341.camel@linux.ibm.com> (raw)
In-Reply-To: <m25y95j2gg.fsf@redhat.com>

On Fri, 2023-05-05 at 14:35 +0200, Christophe de Dinechin wrote:
> 
> On 2023-05-04 at 13:04 -04, James Bottomley <jejb@linux.ibm.com>
> wrote...
> > On Wed, 2023-05-03 at 14:26 +0200, Jörg Rödel wrote:
[...]
> > > And here come the 'BUT': Since the goal of having one project is
> > > to bundle community efforts, I think that the joint efforts are
> > > better targeted at getting CPL-3 support to a point where it can
> > > run modules. On that side some input and help is needed,
> > > especially to define the syscall interface so that it suits the
> > > needs of a TPM implementation.
> > 
> > Crypto support in ring-0 is unavoidable if we want to retain
> > control of the VMPCK0 key in ring-0.  I can't see us giving it to
> > ring-3 because that would give up control of the SVSM identity and
> > basically make the ring-0 separation useless because you can
> > compromise ring-3 and get the key and then communicate with the PSP
> > as the SVSM.
> 
> I'm a but confused regarding the roles that VMPL vs rings is in the
> security model here.

Heh, I think that goes for everyone, which is why I'm fishing for
information about the security model.  I don't think its enough to
blindly claim running at cpl3 gives more security, you have to have a
threat model that demonstrates it.

>  In particular, I assume that any attack on ring3 would
> still have to cross either the VMPL boundary (if coming from the
> guest) or the TEE boundary (if coming from the host).

I think the attack theory is more like a privilege escalation: you
induce the SVSM to take a fault through its normal API mechanism by
crafting bad data (this means the runtime attack can only come from the
guest since the host doesn't get access to the SVSM at runtime,
although it could craft bad configuration data for boot time).

Assuming a successful exploit, the attacker now has the ability to run
code in the compromised module.  For a unitary SVSM, that would give
control of the entire SVSM.  For ring 0/3 separation, it should only
give control of the compromised module, which we're assuming is ring 3
code.  However, you're right, in that the attacker now has the ability
to execute VPML0 code, except that some privileged instructions (like
PVALIDATE) can only execute at ring 0, so the attack ability is
slightly more limited.

I've always considered the gold standard exploit of the SVSM to be one
that allows you to fake attestation reports, since then it's game over
as far as remote verification goes, which is why I want the VMPCK0 key
(the communication key VPML0 uses to get VMPL0 specific attestation
reports from the PSP) to be closely guarded at ring 0, making it harder
to compromise remote attestation via exploits.

The flip side is that, assuming the vTPM is the compromised service,
you've already got the ability to fake TPM based runtime attestation,
so its still game over from the remote attestation point of view.  This
leads me to conclude that it really doesn't matter where security
critical protocols run, and the only real advantage of the ring 0/3
separation would come into play if the SVSM had some non-security
critical protocols and it's not clear if it ever will.

> > I think the above problem also indicates no-one really has a fully
> > thought out security model that shows practically how ring-3
> > improves the security posture.  So I really think starting in ring-
> > 0 and then moving pieces to ring-3 and discussing whether this
> > materially improves the security posture based on the code and how
> > it operates gets us around the lack of understanding of the
> > security model because we proceed by evolution.
> 
> And there is definitely a lot of complexity added by supporting
> ring3. You are essentially getting the complexity of a "real"
> operating system.  By contrast, TDX is providing the same kind of
> isolation with secure enclaves, but at least the base OS kernel is
> shared.
> 
> The expected benefit is to be able to run more complex code from
> ring3 with a better way to handle malfunctions, faults, whatever. At
> least that's the way I read it. So it's a way to write software in a
> more modular way.

Yes, but is that a benefit?  If one of the protocol modules faults, I
think you'd rather have a hard failure of the whole confidential VM
than a restart that gives an attacker more leeway to craft a
compromise.

> IIUC, the ring-3 modules of the SVSM would still be at VMPL0, so
> presumably, not accesible from host or guest. If we consider this
> property as strong, then do we really care entrusting ring3 with
> sensitive data?

Well, as I said above, I think for security critical modules, it
doesn't matter where they run, so perhaps we don't care, but equally
there's not much security benefit to ring 0/3 separation either.

> > The next question that's going to arise is *where* the crypto
> > libraries should reside.  Given they're somewhat large, duplicating
> > them for every cpl-3 application plus cpl-3 seems wasteful, so some
> > type of vdso model sounds better (and might work instead of a
> > syscall interfaces for cpl-0 services that are pure code).
> 
> I don't understand what you call "pure code". I presume you mean
> "code that does not need to access ring0 data"?

I was meaning a VDSO like model, where the openssl crypto code could be
exported from ring-0 as an executable library, but the data would live
with the corresponding consumer, so it could be used by the SVSM body
at ring-0 with any crypto data being held at ring-0 and inaccessible to
ring-3 consumers of the crypto code.

James


  reply	other threads:[~2023-05-06 12:48 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21  9:29 [ANNOUNCEMENT] COCONUT Secure VM Service Module for SEV-SNP Jörg Rödel
2023-03-21 11:09 ` James Bottomley
2023-03-21 12:43   ` Jörg Rödel
2023-03-21 13:43     ` James Bottomley
2023-03-21 15:14       ` Jörg Rödel
2023-03-21 17:48         ` Dr. David Alan Gilbert
2023-03-21 18:50           ` Jörg Rödel
2023-03-21 20:05         ` James Bottomley
2023-03-22  1:29           ` Marc Orr
2023-03-22 17:57             ` Daniel P. Berrangé
2023-03-22  9:15           ` Jörg Rödel
2023-03-22 18:07             ` Daniel P. Berrangé
2023-03-22 18:24               ` Dionna Amalie Glaze
2023-03-21 15:06 ` Dr. David Alan Gilbert
2023-03-21 15:25   ` Jörg Rödel
2023-03-21 16:56     ` Dr. David Alan Gilbert
2023-03-21 19:03       ` Jörg Rödel
2023-03-21 19:53         ` Dr. David Alan Gilbert
2023-03-22  9:19           ` Jörg Rödel
2023-03-22  9:43             ` Alexander Graf
2023-03-22 10:34               ` Dr. David Alan Gilbert
2023-03-22 17:37                 ` Dionna Amalie Glaze
2023-03-22 17:47                   ` Dr. David Alan Gilbert
2023-03-22 21:53                     ` James Bottomley
2023-04-11 19:57 ` Tom Lendacky
2023-04-11 20:01   ` Dionna Amalie Glaze
2023-04-13 16:57   ` James Bottomley
2023-04-14  9:00     ` Jörg Rödel
2023-05-02 23:03 ` Tom Lendacky
2023-05-03 12:26   ` Jörg Rödel
2023-05-03 15:24     ` Dionna Amalie Glaze
2023-05-03 15:43       ` James Bottomley
2023-05-03 16:10       ` Daniel P. Berrangé
2023-05-03 16:51     ` Claudio Carvalho
2023-05-03 17:16       ` Alexander Graf
2023-05-05 15:34       ` Jörg Rödel
2023-05-05 15:47         ` Daniel P. Berrangé
2023-05-04 17:04     ` James Bottomley
2023-05-05 12:35       ` Christophe de Dinechin
2023-05-06 12:48         ` James Bottomley [this message]
2023-05-08  5:16           ` Alexander Graf
2023-05-05 15:02       ` Jörg Rödel

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=2f1c0527ab42dee7d4eaf562c6a14851bb64c341.camel@linux.ibm.com \
    --to=jejb@linux.ibm.com \
    --cc=amd-sev-snp@lists.suse.com \
    --cc=dinechin@redhat.com \
    --cc=jroedel@suse.de \
    --cc=kkiwi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=thomas.lendacky@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).