[PATCH v3 02/10] tpm: Use -EPERM as fallback error code in tpm_ret_to_err

Jarkko Sakkinen posted 10 patches 2 days, 5 hours ago
There is a newer version of this series
[PATCH v3 02/10] tpm: Use -EPERM as fallback error code in tpm_ret_to_err
Posted by Jarkko Sakkinen 2 days, 5 hours ago
From: Jarkko Sakkinen <jarkko.sakkinen@opinsys.com>

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>
---
v3:
- Removed fixes tag as it hardly categorizes as a bug fix.
v2:
- Split trusted_tpm2 change to a separate patch.
---
 include/linux/tpm.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index fc7df87dfb9a..51846317d662 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -453,8 +453,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;
 	}
 }
 
-- 
2.39.5
Re: [PATCH v3 02/10] tpm: Use -EPERM as fallback error code in tpm_ret_to_err
Posted by Stefano Garzarella 1 day, 12 hours ago
On Mon, Sep 29, 2025 at 10:48:24PM +0300, Jarkko Sakkinen wrote:
>From: Jarkko Sakkinen <jarkko.sakkinen@opinsys.com>
>
>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>
>---
>v3:
>- Removed fixes tag as it hardly categorizes as a bug fix.
>v2:
>- Split trusted_tpm2 change to a separate patch.
>---
> include/linux/tpm.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)

LGTM now!

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/include/linux/tpm.h b/include/linux/tpm.h
>index fc7df87dfb9a..51846317d662 100644
>--- a/include/linux/tpm.h
>+++ b/include/linux/tpm.h
>@@ -453,8 +453,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;
> 	}
> }
>
>-- 
>2.39.5
>
>
Re: [PATCH v3 02/10] tpm: Use -EPERM as fallback error code in tpm_ret_to_err
Posted by Jarkko Sakkinen 1 day, 12 hours ago
On Tue, Sep 30, 2025 at 02:11:23PM +0200, Stefano Garzarella wrote:
> On Mon, Sep 29, 2025 at 10:48:24PM +0300, Jarkko Sakkinen wrote:
> > From: Jarkko Sakkinen <jarkko.sakkinen@opinsys.com>
> > 
> > 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>
> > ---
> > v3:
> > - Removed fixes tag as it hardly categorizes as a bug fix.
> > v2:
> > - Split trusted_tpm2 change to a separate patch.
> > ---
> > include/linux/tpm.h | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> LGTM now!
> 
> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

Thank you.

> 
> > 
> > diff --git a/include/linux/tpm.h b/include/linux/tpm.h
> > index fc7df87dfb9a..51846317d662 100644
> > --- a/include/linux/tpm.h
> > +++ b/include/linux/tpm.h
> > @@ -453,8 +453,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;
> > 	}
> > }
> > 
> > -- 
> > 2.39.5
> > 
> > 
> 

BR, Jarkko