Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1470330
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] tpm: fix a race condition tpm2_unseal_trusted() |
| Date | 2016-08-25 20:40 +0200 |
| Message-ID | <sa7Jf-4CP-7@gated-at.bofh.it> (permalink) |
| References | <s9uHT-39E-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] tpm: fix a race condition tpm2_unseal_trusted() Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-08-24 03:00 +0200
Re: [PATCH] tpm: fix a race condition tpm2_unseal_trusted() Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-08-24 03:50 +0200
Re: [PATCH] tpm: fix a race condition tpm2_unseal_trusted() Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-08-25 20:40 +0200
Re: [PATCH] tpm: fix a race condition tpm2_unseal_trusted() Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-08-25 23:20 +0200
Re: [PATCH] tpm: fix a race condition tpm2_unseal_trusted() Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-08-26 00:40 +0200
csiph-web