On Wed, Sep 30, 2020 at 01:51:41AM +0300, Jarkko Sakkinen wrote:
When TPM 2.0 trusted keys code was moved to the trusted keys subsystem, the operations were unwrapped from tpm_try_get_ops() and tpm_put_ops(), which are used to take temporarily the ownership of the TPM chip. The ownership is only taken inside tpm_send(), but this is not sufficient, as in the key load TPM2_CC_LOAD, TPM2_CC_UNSEAL and TPM2_FLUSH_CONTEXT need to be done as a one single atom.
Fix this issue by introducting trusted_tpm_load() and trusted_tpm_new(), which wrap these operations, and take the TPM chip ownership before sending anything. Use tpm_transmit_cmd() to send TPM commands instead of tpm_send(), reverting back to the old behaviour.
Fixes: 2e19e10131a0 ("KEYS: trusted: Move TPM2 trusted keys code") Reported-by: "James E.J. Bottomley" James.Bottomley@HansenPartnership.com Cc: Sumit Garg sumit.garg@linaro.org Cc: David Howells dhowells@redhat.com Cc: stable@vger.kernel.org Signed-off-by: Jarkko Sakkinen jarkko.sakkinen@linux.intel.com
I double checked that patches were in my BuildRoot rootfs and kernel.
I also did an update to tpm2-scripts:
https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/tpm2-scripts.git/
See the tip commit. That explains my ASN.1 testing issues. Now that test script fully works again in all of my machines.
Lessons learned, or more like, how do we disclose this kind of testing issue in future: I suggest that we migrate keyctl-smoke.sh (can be possibly renamed) to the kernel selftests, and keep it up to date.
It would also degrade possible stability issues in trusted keys if everyone has standard point of reference.
Thoughts?
/Jarkko