• J
    tpm2: add session handle context saving and restoring to the space code · 4d57856a
    James Bottomley 提交于
    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: NJames Bottomley <James.Bottomley@HansenPartnership.com>
    Tested-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    Reviewed-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    4d57856a
tpm.h 14.0 KB