[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160825183059.GB1142@obsidianresearch.com>
Date: Thu, 25 Aug 2016 12:30:59 -0600
From: Jason Gunthorpe <jgunthorpe@...idianresearch.com>
To: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
Cc: Peter Huewe <peterhuewe@....de>,
linux-security-module@...r.kernel.org, stable@...r.kernel.org,
Marcel Selhorst <tpmdd@...horst.net>,
"moderated list:TPM DEVICE DRIVER"
<tpmdd-devel@...ts.sourceforge.net>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] tpm: fix a race condition tpm2_unseal_trusted()
On Tue, Aug 23, 2016 at 08:57:22PM -0400, Jarkko Sakkinen wrote:
> + if (flags & TPM_TRANSMIT_LOCK)
> + mutex_lock(&chip->tpm_mutex);
I think I would invert this. UNLOCKED is the exceptional case, so I'd
make the 0 flags lock. If we see UNLOCKED in the caller then we know
to audit for locking, 0 is much less obvious.
> @@ -576,7 +576,7 @@ 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, "loading blob", 0);
All these points should accept a flags too and the caller should pass
in the TPM_TRASNMIT_UNLOCKED if it needs it..
> + mutex_lock(&chip->tpm_mutex);
> rc = tpm2_load(chip, payload, options, &blob_handle);
> if (rc)
So when we read here we see the pattern:
> + mutex_lock(&chip->tpm_mutex);
> rc = tpm2_load(chip, payload, options, &blob_handle, TPM_TRASNMIT_UNLOCKED);
Which is much easier to audit..
Jason
Powered by blists - more mailing lists