public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Peter Huewe <peterhuewe@gmx.de>, Marcel Selhorst <tpmdd@selhorst.net>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	"moderated list:TPM DEVICE DRIVER" 
	<tpmdd-devel@lists.sourceforge.net>,
	open list <linux-kernel@vger.kernel.org>,
	linux-security-module@vger.kernel.org
Subject: Re: [PATCH 3/3] tpm: fix missing migratable flag in sealing functionality for TPM2
Date: Mon, 9 Nov 2015 11:51:19 +0200	[thread overview]
Message-ID: <20151109095119.GA11250@intel.com> (raw)
In-Reply-To: <1446718824-5249-4-git-send-email-jarkko.sakkinen@linux.intel.com>

Hi

Other fixes are ready for the pull request but for this patch peer
check might be useful.

I'm anyway sending the pull request with the five pull patches over
here even if I don't get 'Tested-by:':

https://github.com/jsakkine/linux-tpmdd/commits/fixes

I've tested this patch with fTPM and dTPM and it does not have any
side-effects to TPM 1.2.

/Jarkko

On Thu, Nov 05, 2015 at 12:20:23PM +0200, Jarkko Sakkinen wrote:
> The 'migratable' flag was not added to the key payload. This patch
> fixes the problem.
> 
> Fixes: 0fe5480303a1 ("keys, trusted: seal/unseal with TPM 2.0 chips")
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
>  drivers/char/tpm/tpm2-cmd.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
> index bd7039f..c121304 100644
> --- a/drivers/char/tpm/tpm2-cmd.c
> +++ b/drivers/char/tpm/tpm2-cmd.c
> @@ -443,12 +443,13 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
>  			     TPM_DIGEST_SIZE);
>  
>  	/* sensitive */
> -	tpm_buf_append_u16(&buf, 4 + TPM_DIGEST_SIZE + payload->key_len);
> +	tpm_buf_append_u16(&buf, 4 + TPM_DIGEST_SIZE + payload->key_len + 1);
>  
>  	tpm_buf_append_u16(&buf, TPM_DIGEST_SIZE);
>  	tpm_buf_append(&buf, options->blobauth, TPM_DIGEST_SIZE);
> -	tpm_buf_append_u16(&buf, payload->key_len);
> +	tpm_buf_append_u16(&buf, payload->key_len + 1);
>  	tpm_buf_append(&buf, payload->key, payload->key_len);
> +	tpm_buf_append_u8(&buf, payload->migratable);
>  
>  	/* public */
>  	tpm_buf_append_u16(&buf, 14);
> @@ -573,6 +574,8 @@ static int tpm2_unseal(struct tpm_chip *chip,
>  		       u32 blob_handle)
>  {
>  	struct tpm_buf buf;
> +	u16 data_len;
> +	u8 *data;
>  	int rc;
>  
>  	rc = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_UNSEAL);
> @@ -591,11 +594,13 @@ static int tpm2_unseal(struct tpm_chip *chip,
>  		rc = -EPERM;
>  
>  	if (!rc) {
> -		payload->key_len = be16_to_cpup(
> +		data_len = be16_to_cpup(
>  			(__be16 *) &buf.data[TPM_HEADER_SIZE + 4]);
> +		data = &buf.data[TPM_HEADER_SIZE + 6];
>  
> -		memcpy(payload->key, &buf.data[TPM_HEADER_SIZE + 6],
> -		       payload->key_len);
> +		memcpy(payload->key, data, data_len - 1);
> +		payload->key_len = data_len - 1;
> +		payload->migratable = data[data_len - 1];
>  	}
>  
>  	tpm_buf_destroy(&buf);
> -- 
> 2.5.0
> 

      reply	other threads:[~2015-11-09  9:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-05 10:20 [PATCH 0/3] Fixes for v4.4-rc1 Jarkko Sakkinen
2015-11-05 10:20 ` [PATCH 1/3] TPM: Avoid reference to potentially freed memory Jarkko Sakkinen
2015-11-05 10:20 ` [PATCH 2/3] TPM: revert the list handling logic fixed in 398a1e7 Jarkko Sakkinen
2015-11-05 10:20 ` [PATCH 3/3] tpm: fix missing migratable flag in sealing functionality for TPM2 Jarkko Sakkinen
2015-11-09  9:51   ` Jarkko Sakkinen [this message]

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=20151109095119.GA11250@intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=tpmdd-devel@lists.sourceforge.net \
    --cc=tpmdd@selhorst.net \
    --cc=zohar@linux.vnet.ibm.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