All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Jarkko Sakkinen
	<jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: open list <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"moderated list:TPM DEVICE DRIVER"
	<tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: [PATCH] tpm: fix a race condition in tpm2_unseal_trusted()
Date: Sun, 28 Aug 2016 12:51:49 -0600	[thread overview]
Message-ID: <20160828185149.GF12783@obsidianresearch.com> (raw)
In-Reply-To: <1472366212-8571-1-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

On Sun, Aug 28, 2016 at 08:36:52AM +0200, Jarkko Sakkinen wrote:
>  
> @@ -576,7 +576,8 @@ static int tpm2_load(struct tpm_chip *chip,
>  		goto out;
>  	}
>  
> -	rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "loading blob");
> +	rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, TPM_TRANSMIT_UNLOCKED,
> +			      "loading blob");

I still don't like this, required mutex's should not be split outside the
function that needs them without more a more obvious indication:

> +	mutex_lock(&chip->tpm_mutex);
>  	rc = tpm2_load(chip, payload, options, &blob_handle);
>  	if (rc)
> -		return rc;

I recommend you stick with the idiom and do this:

        mutex_lock(&chip->tpm_mutex);
  	rc = tpm2_load(chip, payload, options, &blob_handle, TPM_TRANSMIT_UNLOCKED);

Which makes it easy to see we are doing it right everywhere.

Jason

------------------------------------------------------------------------------

WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Peter Huewe <peterhuewe@gmx.de>,
	linux-security-module@vger.kernel.org, stable@vger.kernel.org,
	Marcel Selhorst <tpmdd@selhorst.net>,
	"moderated list:TPM DEVICE DRIVER" 
	<tpmdd-devel@lists.sourceforge.net>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tpm: fix a race condition in tpm2_unseal_trusted()
Date: Sun, 28 Aug 2016 12:51:49 -0600	[thread overview]
Message-ID: <20160828185149.GF12783@obsidianresearch.com> (raw)
In-Reply-To: <1472366212-8571-1-git-send-email-jarkko.sakkinen@linux.intel.com>

On Sun, Aug 28, 2016 at 08:36:52AM +0200, Jarkko Sakkinen wrote:
>  
> @@ -576,7 +576,8 @@ static int tpm2_load(struct tpm_chip *chip,
>  		goto out;
>  	}
>  
> -	rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "loading blob");
> +	rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, TPM_TRANSMIT_UNLOCKED,
> +			      "loading blob");

I still don't like this, required mutex's should not be split outside the
function that needs them without more a more obvious indication:

> +	mutex_lock(&chip->tpm_mutex);
>  	rc = tpm2_load(chip, payload, options, &blob_handle);
>  	if (rc)
> -		return rc;

I recommend you stick with the idiom and do this:

        mutex_lock(&chip->tpm_mutex);
  	rc = tpm2_load(chip, payload, options, &blob_handle, TPM_TRANSMIT_UNLOCKED);

Which makes it easy to see we are doing it right everywhere.

Jason

  parent reply	other threads:[~2016-08-28 18:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-28  6:36 [PATCH] tpm: fix a race condition in tpm2_unseal_trusted() Jarkko Sakkinen
2016-08-28  6:36 ` Jarkko Sakkinen
     [not found] ` <1472366212-8571-1-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-08-28 18:51   ` Jason Gunthorpe [this message]
2016-08-28 18:51     ` Jason Gunthorpe
2016-08-29 15:25     ` Jarkko Sakkinen
     [not found]       ` <20160829152520.GA9063-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-08-29 19:21         ` Jason Gunthorpe
2016-08-29 19:21           ` Jason Gunthorpe
2016-08-29 19:40           ` Jarkko Sakkinen
2016-08-29 20:03             ` Jarkko Sakkinen
     [not found]               ` <20160829200326.GA6758-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-08-29 20:07                 ` Jason Gunthorpe
2016-08-29 20:07                   ` Jason Gunthorpe

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=20160828185149.GF12783@obsidianresearch.com \
    --to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
    --cc=jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.