linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: david.safford@gmail.com
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
	James Bottomley <jejb@linux.ibm.com>,
	Mimi Zohar <zohar@linux.ibm.com>,
	David Howells <dhowells@redhat.com>,
	James Morris <jmorris@namei.org>,
	"SergeE.Hallyn" <serge@hallyn.com>,
	linux-integrity@vger.kernel.org, keyrings@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] KEYS: trusted: tpm2: Fix migratable logic
Date: Wed, 8 Jun 2022 08:47:38 +0300	[thread overview]
Message-ID: <YqA3+vfte7RbbGBa@iki.fi> (raw)
In-Reply-To: <141492344ae13c9842626e696685316ee340d717.camel@gmail.com>

On Tue, Jun 07, 2022 at 02:07:57PM -0400, david.safford@gmail.com wrote:
> When creating (sealing) a new trusted key, migratable
> trusted keys have the FIXED_TPM and FIXED_PARENT attributes
> set, and non-migratable keys don't. This is backwards, and
> also causes creation to fail when creating a migratable key
> under a migratable parent. (The TPM thinks you are trying to
> seal a non-migratable blob under a migratable parent.)
> 
> The following simple patch fixes the logic, and has been
> tested for all four combinations of migratable and non-migratable
> trusted keys and parent storage keys. With this logic, you will
> get a proper failure if you try to create a non-migratable
> trusted key under a migratable parent storage key, and all other
> combinations work correctly.
> 
> Fixes: e5fb5d2c5a03 ("security: keys: trusted: Make sealed key properly interoperable")
> Signed-off-by: David Safford <david.safford@gmail.com>
> ---
> Changelog:
>  * v2:
>    * added Signed-off-by, Fixes, proper Subject and distribution
> .
>  security/keys/trusted-keys/trusted_tpm2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
> index 0165da386289..2b2c8eb258d5 100644
> --- a/security/keys/trusted-keys/trusted_tpm2.c
> +++ b/security/keys/trusted-keys/trusted_tpm2.c
> @@ -283,8 +283,8 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
>  	/* key properties */
>  	flags = 0;
>  	flags |= options->policydigest_len ? 0 : TPM2_OA_USER_WITH_AUTH;
> -	flags |= payload->migratable ? (TPM2_OA_FIXED_TPM |
> -					TPM2_OA_FIXED_PARENT) : 0;
> +	flags |= payload->migratable ? 0 : (TPM2_OA_FIXED_TPM |
> +					    TPM2_OA_FIXED_PARENT);
>  	tpm_buf_append_u32(&buf, flags);
> 
>  	/* policy */
> --
> 2.36.1

David, thanks a lot for fixing this (what an embarrassing bug)!

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

      parent reply	other threads:[~2022-06-08  7:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 18:07 [PATCH v2] KEYS: trusted: tpm2: Fix migratable logic david.safford
2022-06-07 18:52 ` Ahmad Fatoum
2022-06-08  5:47 ` 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=YqA3+vfte7RbbGBa@iki.fi \
    --to=jarkko@kernel.org \
    --cc=a.fatoum@pengutronix.de \
    --cc=david.safford@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=jejb@linux.ibm.com \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=zohar@linux.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;
as well as URLs for NNTP newsgroup(s).