]> Gentwo Git Trees - linux/.git/commitdiff
tpm: Use -EPERM as fallback error code in tpm_ret_to_err
authorJarkko Sakkinen <jarkko.sakkinen@opinsys.com>
Tue, 30 Sep 2025 13:02:54 +0000 (16:02 +0300)
committerJarkko Sakkinen <jarkko@kernel.org>
Wed, 3 Dec 2025 20:55:28 +0000 (22:55 +0200)
Using -EFAULT as the tpm_ret_to_err() fallback error code causes makes it
incompatible on how trusted keys transmute TPM return codes.

Change the fallback as -EPERM in order to gain compatibility with trusted
keys. In addition, map TPM_RC_HASH to -EINVAL in order to be compatible
with tpm2_seal_trusted() return values.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@opinsys.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
include/linux/tpm.h

index 53de9488c509ec64de45bb29b9a4c8a5dcad22ae..3d8f7d1ce2b8c18858685031820b564153131df1 100644 (file)
@@ -456,8 +456,10 @@ static inline ssize_t tpm_ret_to_err(ssize_t ret)
                return 0;
        case TPM2_RC_SESSION_MEMORY:
                return -ENOMEM;
+       case TPM2_RC_HASH:
+               return -EINVAL;
        default:
-               return -EFAULT;
+               return -EPERM;
        }
 }