* Re: [PATCH] KEYS: trusted: caam: propagate protected key option parsing errors
2026-11-24 15:53 [PATCH] KEYS: trusted: caam: propagate protected key option parsing errors Keisuke Tsukuda
@ 2026-11-24 16:37 ` Serge E. Hallyn
2026-11-24 17:46 ` Jarkko Sakkinen
2026-11-26 8:44 ` Ahmad Fatoum
2 siblings, 0 replies; 4+ messages in thread
From: Serge E. Hallyn @ 2026-11-24 16:37 UTC (permalink / raw)
To: Keisuke Tsukuda, Meenakshi Aggarwal
Cc: a.fatoum, kernel, James.Bottomley@HansenPartnership.com, jarkko,
zohar, dhowells, paul, jmorris, linux-integrity, keyrings,
linux-security-module, linux-kernel
On Tue, Nov 24, 2026 at 03:53:39PM +0000, Keisuke Tsukuda wrote:
> From: Keisuke Tsukuda <tkdkei@outlook.jp>
>
> get_pkey_options() returns -EINVAL for invalid protected key options,
> such as "key_enc_algo=GG". trusted_caam_seal() and trusted_caam_unseal()
> ignore this error and return 0. The trusted key core then instantiates
> a key without a blob for "new", or with a zero-length key for "load".
>
> On an i.MX6Q running a 7.4.0-rc2-based kernel, adding a key with
> "new 32 pk key_enc_algo=GG" succeeds, but KEYCTL_READ returns zero
> bytes because no blob was created. The key cannot be saved and
> reloaded.
>
> Return the parsing error from both paths. On the patched kernel,
> "new" and "load" with "key_enc_algo=GG" both fail with -EINVAL, while
> valid requests succeed.
>
> Fixes: a703a4c2a328 ("KEYS: trusted: caam based protected key")
> Signed-off-by: Keisuke Tsukuda <tkdkei@outlook.jp>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
But, it looks like these were both added by
commit a703a4c2a3280835003d4d0eb8845bac0f1a6ef1
Author: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Date: Mon Oct 6 09:17:52 2025 +0200
KEYS: trusted: caam based protected key
Adding Meenakshi to the thread to make sure this wasn't intentional,
and serving some purpose we're overlooking.
> ---
> security/keys/trusted-keys/trusted_caam.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/security/keys/trusted-keys/trusted_caam.c b/security/keys/trusted-keys/trusted_caam.c
> index 6a33dbf2a..33000d7bb 100644
> --- a/security/keys/trusted-keys/trusted_caam.c
> +++ b/security/keys/trusted-keys/trusted_caam.c
> @@ -110,7 +110,7 @@ static int trusted_caam_seal(struct trusted_key_payload *p, char *datablob)
> info.pkey_info.is_pkey = 1;
> ret = get_pkey_options(datablob, &info.pkey_info);
> if (ret < 0)
> - return 0;
> + return ret;
> dump_options(&info.pkey_info);
> }
>
> @@ -142,7 +142,7 @@ static int trusted_caam_unseal(struct trusted_key_payload *p, char *datablob)
> info.pkey_info.is_pkey = 1;
> ret = get_pkey_options(datablob, &info.pkey_info);
> if (ret < 0)
> - return 0;
> + return ret;
> dump_options(&info.pkey_info);
>
> p->key_len = p->blob_len + sizeof(struct caam_pkey_info);
> --
> 2.50.1 (Apple Git-155)
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] KEYS: trusted: caam: propagate protected key option parsing errors
2026-11-24 15:53 [PATCH] KEYS: trusted: caam: propagate protected key option parsing errors Keisuke Tsukuda
2026-11-24 16:37 ` Serge E. Hallyn
@ 2026-11-24 17:46 ` Jarkko Sakkinen
2026-11-26 8:44 ` Ahmad Fatoum
2 siblings, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2026-11-24 17:46 UTC (permalink / raw)
To: Keisuke Tsukuda
Cc: a.fatoum, kernel, James.Bottomley@HansenPartnership.com, zohar,
dhowells, paul, jmorris, serge, linux-integrity, keyrings,
linux-security-module, linux-kernel
On Tue, Nov 24, 2026 at 03:53:39PM +0000, Keisuke Tsukuda wrote:
> From: Keisuke Tsukuda <tkdkei@outlook.jp>
>
> get_pkey_options() returns -EINVAL for invalid protected key options,
> such as "key_enc_algo=GG". trusted_caam_seal() and trusted_caam_unseal()
> ignore this error and return 0. The trusted key core then instantiates
> a key without a blob for "new", or with a zero-length key for "load".
>
> On an i.MX6Q running a 7.4.0-rc2-based kernel, adding a key with
> "new 32 pk key_enc_algo=GG" succeeds, but KEYCTL_READ returns zero
> bytes because no blob was created. The key cannot be saved and
> reloaded.
>
> Return the parsing error from both paths. On the patched kernel,
> "new" and "load" with "key_enc_algo=GG" both fail with -EINVAL, while
> valid requests succeed.
>
> Fixes: a703a4c2a328 ("KEYS: trusted: caam based protected key")
> Signed-off-by: Keisuke Tsukuda <tkdkei@outlook.jp>
> ---
> security/keys/trusted-keys/trusted_caam.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/security/keys/trusted-keys/trusted_caam.c b/security/keys/trusted-keys/trusted_caam.c
> index 6a33dbf2a..33000d7bb 100644
> --- a/security/keys/trusted-keys/trusted_caam.c
> +++ b/security/keys/trusted-keys/trusted_caam.c
> @@ -110,7 +110,7 @@ static int trusted_caam_seal(struct trusted_key_payload *p, char *datablob)
> info.pkey_info.is_pkey = 1;
> ret = get_pkey_options(datablob, &info.pkey_info);
> if (ret < 0)
> - return 0;
> + return ret;
> dump_options(&info.pkey_info);
> }
>
> @@ -142,7 +142,7 @@ static int trusted_caam_unseal(struct trusted_key_payload *p, char *datablob)
> info.pkey_info.is_pkey = 1;
> ret = get_pkey_options(datablob, &info.pkey_info);
> if (ret < 0)
> - return 0;
> + return ret;
> dump_options(&info.pkey_info);
>
> p->key_len = p->blob_len + sizeof(struct caam_pkey_info);
> --
> 2.50.1 (Apple Git-155)
>
Thanks.
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Br, Jarkko
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] KEYS: trusted: caam: propagate protected key option parsing errors
2026-11-24 15:53 [PATCH] KEYS: trusted: caam: propagate protected key option parsing errors Keisuke Tsukuda
2026-11-24 16:37 ` Serge E. Hallyn
2026-11-24 17:46 ` Jarkko Sakkinen
@ 2026-11-26 8:44 ` Ahmad Fatoum
2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2026-11-26 8:44 UTC (permalink / raw)
To: Keisuke Tsukuda
Cc: kernel, James.Bottomley, jarkko, zohar, dhowells, paul, jmorris,
serge, linux-integrity, keyrings, linux-security-module,
linux-kernel
On 11/24/26 16:53, Keisuke Tsukuda wrote:
> From: Keisuke Tsukuda <tkdkei@outlook.jp>
>
> get_pkey_options() returns -EINVAL for invalid protected key options,
> such as "key_enc_algo=GG". trusted_caam_seal() and trusted_caam_unseal()
> ignore this error and return 0. The trusted key core then instantiates
> a key without a blob for "new", or with a zero-length key for "load".
>
> On an i.MX6Q running a 7.4.0-rc2-based kernel, adding a key with
> "new 32 pk key_enc_algo=GG" succeeds, but KEYCTL_READ returns zero
> bytes because no blob was created. The key cannot be saved and
> reloaded.
>
> Return the parsing error from both paths. On the patched kernel,
> "new" and "load" with "key_enc_algo=GG" both fail with -EINVAL, while
> valid requests succeed.
>
> Fixes: a703a4c2a328 ("KEYS: trusted: caam based protected key")
> Signed-off-by: Keisuke Tsukuda <tkdkei@outlook.jp>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> security/keys/trusted-keys/trusted_caam.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/security/keys/trusted-keys/trusted_caam.c b/security/keys/trusted-keys/trusted_caam.c
> index 6a33dbf2a..33000d7bb 100644
> --- a/security/keys/trusted-keys/trusted_caam.c
> +++ b/security/keys/trusted-keys/trusted_caam.c
> @@ -110,7 +110,7 @@ static int trusted_caam_seal(struct trusted_key_payload *p, char *datablob)
> info.pkey_info.is_pkey = 1;
> ret = get_pkey_options(datablob, &info.pkey_info);
> if (ret < 0)
> - return 0;
> + return ret;
> dump_options(&info.pkey_info);
> }
>
> @@ -142,7 +142,7 @@ static int trusted_caam_unseal(struct trusted_key_payload *p, char *datablob)
> info.pkey_info.is_pkey = 1;
> ret = get_pkey_options(datablob, &info.pkey_info);
> if (ret < 0)
> - return 0;
> + return ret;
> dump_options(&info.pkey_info);
>
> p->key_len = p->blob_len + sizeof(struct caam_pkey_info);
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread