Re: [PATCH] tpm: fix a race condition tpm2_unseal_trusted()

From: Jason Gunthorpe
Date: Wed Jul 20 2016 - 12:48:42 EST


On Wed, Jul 20, 2016 at 03:16:32AM +0300, Jarkko Sakkinen wrote:
> Unseal and load operations should be done as an atomic unit. This
> commit fixes the issue by moving TPM mutex handling to tpm_try_get_ops()
> and tpm_put_ops(), which is probably more logical place for it anyway.

No..

'get_ops' is to be used to hold a persisent kref to a single tpm. It
cannot block other tpm access.

Eg a upper protocol might get_ops to for a long period to ensure it
consistently talks to the same TPM in a multi-tpm system.

We need something else to solve whatever you are concerned with
here..

Jason