linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Fuchs, Andreas" <andreas.fuchs@sit.fraunhofer.de>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: "tpmdd-devel@lists.sourceforge.net" 
	<tpmdd-devel@lists.sourceforge.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	David Howells <dhowells@redhat.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"open list:KEYS-TRUSTED" <linux-security-module@vger.kernel.org>,
	"open list:KEYS-TRUSTED" <keyrings@vger.kernel.org>,
	James Morris <james.l.morris@oracle.com>,
	"David Safford" <safford@us.ibm.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"Serge E. Hallyn" <serge@hallyn.com>
Subject: RE: [tpmdd-devel] [PATCH 4/4] keys,	trusted: seal/unseal with TPM 2.0 chips
Date: Sun, 4 Oct 2015 18:57:42 +0000	[thread overview]
Message-ID: <9F48E1A823B03B4790B7E6E69430724D9D7AE4FB@EXCH2010A.sit.fraunhofer.de> (raw)
In-Reply-To: <20151003102655.GA9372@intel.com>

Hi Jarkko,

thanks for the clearification...

However, I'd recommend against doing so.
Furthermore, if there is a resource-manager running in userspace, applications only get virtual handles and TPM might be empty actually...

If that's what you're aiming for, I'd recommend passing the pointer to a context-saved-blob and have the kernel load the key this way. That ensures no problems with resource-manager and handle-mixups.

Cheers,
Andreas
________________________________________
From: Jarkko Sakkinen [jarkko.sakkinen@linux.intel.com]
Sent: Saturday, October 03, 2015 12:26
To: Fuchs, Andreas
Cc: tpmdd-devel@lists.sourceforge.net; linux-kernel@vger.kernel.org; David Howells; gregkh@linuxfoundation.org; open list:KEYS-TRUSTED; open list:KEYS-TRUSTED; James Morris; David Safford; akpm@linux-foundation.org; Serge E. Hallyn
Subject: Re: [tpmdd-devel] [PATCH 4/4] keys,    trusted: seal/unseal with TPM 2.0 chips

On Sat, Oct 03, 2015 at 10:00:59AM +0000, Fuchs, Andreas wrote:
> Hi Jarkko,
>
> [snip]
>
> diff --git a/security/keys/trusted.h b/security/keys/trusted.h
> index ff001a5..fc32c47 100644
> --- a/security/keys/trusted.h
> +++ b/security/keys/trusted.h
> @@ -12,6 +12,13 @@
>  #define TPM_RETURN_OFFSET              6
>  #define TPM_DATA_OFFSET                        10
>
> +/* Transient object handles start from 0x80000000 in TPM 2.0, which makes it
> + * a sane default.
> + */
> +
> +#define TPM1_SRKHANDLE 0x40000000
> +#define TPM2_SRKHANDLE 0x80000000
> +
>  #define LOAD32(buffer, offset) (ntohl(*(uint32_t *)&buffer[offset]))
>  #define LOAD32N(buffer, offset)        (*(uint32_t *)&buffer[offset])
>  #define LOAD16(buffer, offset) (ntohs(*(uint16_t *)&buffer[offset]))
>
> This TPM2_SRKHANDLE is unfortunately wrong.
>
> Transient handles are assigned and returned by the TPM following the
> commands TPM2_CreatePrimary, TPM2_LoadObject and TPM2_ContextLoad. You
> can only use transient handles as returned by the TPM in order to
> refer to the corresponding object created inside the TPM via these
> commands. They can never assumed to be constant. The fact that TPMs
> return 0x80000000 for the first loaded Object and 0x80000001 for the
> second is merely a coincidence... ;-)
>
> TPM2 also has no (single) SRK anymore. You have to create your own SRK
> / Storage Primary Keys via TPM2_CreatePrimary and use the transient
> handle returned from there. This however requires SH-authorization,
> usually via Policy IMHO, so not easy to manage. So IMHO, this might be
> something for the future but for the moment relying on a persistent
> key would be better...
>
> For persistent SRKs it should become a convention to have those
> around. Those handles start with 0x81000000 and the SRKs (or Storage
> primary Keys) shall live within 0x81000000 to 0x8100FFFF (see
> http://www.trustedcomputinggroup.org/resources/registry_of_reserved_tpm_20_handles_and_localities)
>
> I'd recommend to rely on the existence of a handle inside this range
> with an empty auth-value. So maybe install a persistent SRK to
> 0x81000000 via TPM2_EvictControl and then use this from within the
> kernel for anything following.
> P.S. You should check for the key's TPMA_OBJECT to have fixedTPM SET.
> I don't know if there is an actual test for owner-generated SRK
> testing. I'll ask around though...
>
> Note: you can query for handles in this range via
> TPM2_GetCapability(TPM_CAP_HANDLES, 0x81000000) and then look for
> fitting keys.
>
>
> Feel free to discuss other approaches.

I'm fully aware of all what you said. My take was to use 0x800000000 as
a default value if you don't the handle ID explicitly in 'description'
parameter of the add_key() syscall.

> Cheers,
> Andreas

/Jarkko

  parent reply	other threads:[~2015-10-04 18:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02  8:38 [PATCH 0/4] Basic trusted keys support for TPM 2.0 Jarkko Sakkinen
2015-10-02  8:38 ` [PATCH 1/4] tpm: introduce struct tpm_buf Jarkko Sakkinen
2015-10-02  8:38 ` [PATCH 2/4] trusted: move struct trusted_key_options to trusted-type.h Jarkko Sakkinen
2015-10-02  8:38 ` [PATCH 3/4] tpm: seal/unseal for TPM 2.0 Jarkko Sakkinen
2015-10-13 17:34   ` Jason Gunthorpe
2015-10-13 19:49     ` Jarkko Sakkinen
2015-10-02  8:38 ` [PATCH 4/4] keys, trusted: seal/unseal with TPM 2.0 chips Jarkko Sakkinen
2015-10-03 10:00   ` [tpmdd-devel] " Fuchs, Andreas
2015-10-03 10:26     ` Jarkko Sakkinen
2015-10-03 10:35       ` Jarkko Sakkinen
2015-10-04 18:57       ` Fuchs, Andreas [this message]
2015-10-05  8:37         ` Jarkko Sakkinen
2015-10-05  9:00           ` Fuchs, Andreas
2015-10-05 11:56             ` Jarkko Sakkinen
2015-10-05 12:20               ` Fuchs, Andreas
2015-10-05 13:17                 ` Jarkko Sakkinen
2015-10-05 13:36                   ` Fuchs, Andreas
2015-10-05 13:57                     ` Jarkko Sakkinen
2015-10-05 14:13                       ` Fuchs, Andreas
2015-10-05 14:28                         ` Jarkko Sakkinen
2015-10-05 15:20                           ` Arthur, Will C
2015-10-06  6:22                           ` Fuchs, Andreas
2015-10-06 12:26                             ` Jarkko Sakkinen
2015-10-06 13:16                               ` Fuchs, Andreas
2015-10-06 15:05                                 ` Jarkko Sakkinen
2015-10-07 10:04                                   ` Fuchs, Andreas
2015-10-07 10:25                                     ` Jarkko Sakkinen
2015-10-07 10:32                                       ` Fuchs, Andreas
2015-10-07 11:15                                         ` 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=9F48E1A823B03B4790B7E6E69430724D9D7AE4FB@EXCH2010A.sit.fraunhofer.de \
    --to=andreas.fuchs@sit.fraunhofer.de \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=james.l.morris@oracle.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=safford@us.ibm.com \
    --cc=serge@hallyn.com \
    --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).