summaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpmrm-dev.c
diff options
context:
space:
mode:
authorJames Bottomley2017-02-01 00:47:31 +0100
committerJarkko Sakkinen2017-04-03 21:46:02 +0200
commit4d57856a21ed2abe33412e0526cc84bdcf67ea08 (patch)
tree69d2ef5b2dfab9ea14b68f7efdb8e90503cfba57 /drivers/char/tpm/tpmrm-dev.c
parenttpm: expose spaces via a device link /dev/tpmrm<n> (diff)
downloadkernel-qcow2-linux-4d57856a21ed2abe33412e0526cc84bdcf67ea08.tar.gz
kernel-qcow2-linux-4d57856a21ed2abe33412e0526cc84bdcf67ea08.tar.xz
kernel-qcow2-linux-4d57856a21ed2abe33412e0526cc84bdcf67ea08.zip
tpm2: add session handle context saving and restoring to the space code
Sessions are different from transient objects in that their handles may not be virtualized (because they're used for some hmac calculations). Additionally when a session is context saved, a vestigial memory remains in the TPM and if it is also flushed, that will be lost and the session context will refuse to load next time, so the code is updated to flush only transient objects after a context save. Add a separate array (chip->session_tbl) to save and restore sessions by handle. Use the failure of a context save or load to signal that the session has been flushed from the TPM and we can remove its memory from chip->session_tbl. Sessions are also isolated during each instance of a tpm space. This means that spaces shouldn't be able to see each other's sessions and is enforced by ensuring that a space user may only refer to sessions handles that are present in their own chip->session_tbl. Finally when a space is closed, all the sessions belonging to it should be flushed so the handles may be re-used by other spaces. Note that if we get a session save or load error, all sessions are effectively flushed. Even though we restore the session buffer, all the old sessions will refuse to load after the flush and they'll be purged from our session memory. This means that while transient context handling is still soft in the face of errors, session handling is hard (any failure of the model means all sessions are lost). Fixes-from: Colin Ian King <colin.king@canonical.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char/tpm/tpmrm-dev.c')
-rw-r--r--drivers/char/tpm/tpmrm-dev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpmrm-dev.c b/drivers/char/tpm/tpmrm-dev.c
index 630bddce65a8..c636e7fdd1f5 100644
--- a/drivers/char/tpm/tpmrm-dev.c
+++ b/drivers/char/tpm/tpmrm-dev.c
@@ -39,7 +39,7 @@ static int tpmrm_release(struct inode *inode, struct file *file)
struct tpmrm_priv *priv = container_of(fpriv, struct tpmrm_priv, priv);
tpm_common_release(file, fpriv);
- tpm2_del_space(&priv->space);
+ tpm2_del_space(fpriv->chip, &priv->space);
kfree(priv);
return 0;