tpm: fix RC value check in tpm2_seal_trusted
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Wed, 25 Jan 2017 21:00:22 +0000 (23:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 14 May 2017 12:08:19 +0000 (14:08 +0200)
commitc6131528430987246a2bc3f4244b2e001493cfd3
treeec906eea7beb13f3a230be0d547733cb7f6ebc0c
parentc5f7ba5f591162e9ce585d76c3ad415751989edd
tpm: fix RC value check in tpm2_seal_trusted

commit 7d761119a914ec0ac05ec2a5378d1f86e680967d upstream.

The error code handling is broken as any error code that has the same
bits set as TPM_RC_HASH passes. Implemented tpm2_rc_value() helper to
parse the error value from FMT0 and FMT1 error codes so that these types
of mistakes are prevented in the future.

Fixes: 5ca4c20cfd37 ("keys, trusted: select hash algorithm for TPM2 chips")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/tpm/tpm.h
drivers/char/tpm/tpm2-cmd.c