linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <jejb@linux.vnet.ibm.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: linux-security-module@vger.kernel.org,
	tpmdd-devel@lists.sourceforge.net,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tpm: add session handles to the save and restore of the tpm2 space manager
Date: Mon, 16 Jan 2017 15:18:45 -0800	[thread overview]
Message-ID: <1484608725.2540.88.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170116100415.ieyweqjjcg5d3zzd@intel.com>

On Mon, 2017-01-16 at 12:04 +0200, Jarkko Sakkinen wrote:
> On Fri, Jan 13, 2017 at 11:24:13AM -0800, James Bottomley wrote:
> > Session handles are slightly more difficult to manage because any
> > TPM
> > only has a finite number of allowed handles, even if the session
> > has
> > been saved; so when you context save a session, you must not flush
> > it
> > because that would destroy the ability to context load it (you only
> > flush sessions when you're done with them) and the tpm won't re-use
> > the handle.  Additionally, sessions can be flushed as part of the
> > successful execution of a command if the continueSession attribute
> > is
> > clear, so we have to mark any session we find in the command (using
> > TPM2_HT_TAG_FOR_FLUSH) so it can be cleared from the space if the
> > command successfully executes.
> > 
> > Finally, a session may also be cleared by flushing it, so we have
> > to
> > emulate the TPM2_FlushContext command to see if a session is being
> > flushed and manually clear it from the space.
> > 
> > We also fully flush all sessions on device close.
> 
> Some big overview comments without going deeply into details. I will
> use more time for this once the 
> 
> Please do not use handle allocation code for sessions. This commit
> makes the implementation a mess. Just use the phandle directly and
> have array of session phandles for each space.
> 
> I would also almost require to have at minimum two patches: one that
> implements purely isolation and another that implements swapping.
> 
> It might be for example that I want to land TPM spaces with session
> isolation to one release and swapping to n+1 because my hunch tells
> me that it is better to bake the swapping part for a while.
> 
> One more thing. Maybe commit messages should speak uniformally about
> TPM spaces? They are a tool to implement resource manager, not a
> resource manager.

Yes, so Ken also had a reply to this which the Mailing List seems to
have eaten:

> This looks like session handles are virtualized.  I believe that this 
> will break the HMAC for commands (e.g. TPM2_PolicySecret) that have
> a session handle in the handle area.  The session's handle is its 
> "Name" and is included in the cpHash (command parameter hash) data 
> that is HMACed. 

Basically this means that the advice to virtualize session handles in
the TCG RM document is wrong and we have to use physical handles. I'll
redo the implementation for this ... and now, since we'll have nothing
to use as an index, it probably does make sense to have sessions in a
separate array.  I can also separate isolation from context switching
... although I really think this is less optimal: my TPM only allows
three active context handles, so if we don't context switch them
identially to transient object (which it also only allows three of) I'm
going to run out.  I actually redid my openssl_tpm_engine patches so
they use session handles for parameter encryption and HMAC based
authority, so this may end up biting me soon ...

James

  parent reply	other threads:[~2017-01-16 23:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-13 19:24 [PATCH] tpm: add session handles to the save and restore of the tpm2 space manager James Bottomley
2017-01-16 10:04 ` Jarkko Sakkinen
2017-01-16 10:05   ` Jarkko Sakkinen
2017-01-16 23:18   ` James Bottomley [this message]
2017-01-17  7:23     ` Jarkko Sakkinen
2017-01-17 14:18       ` James Bottomley
2017-01-17 16:29         ` Jarkko Sakkinen
     [not found]     ` <o5l849$el9$1@blaine.gmane.org>
2017-01-17 16:21       ` [tpmdd-devel] " 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=1484608725.2540.88.camel@linux.vnet.ibm.com \
    --to=jejb@linux.vnet.ibm.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=tpmdd-devel@lists.sourceforge.net \
    /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).