mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keisuke Tsukuda <tkdkei@outlook.jp>
To: "a.fatoum@pengutronix.de" <a.fatoum@pengutronix.de>
Cc: "kernel@pengutronix.de" <kernel@pengutronix.de>,
	"James.Bottomley@HansenPartnership.com"
	<James.Bottomley@HansenPartnership.com>,
	"jarkko@kernel.org" <jarkko@kernel.org>,
	"zohar@linux.ibm.com" <zohar@linux.ibm.com>,
	"dhowells@redhat.com" <dhowells@redhat.com>,
	"paul@paul-moore.com" <paul@paul-moore.com>,
	"jmorris@namei.org" <jmorris@namei.org>,
	"serge@hallyn.com" <serge@hallyn.com>,
	"linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>,
	"keyrings@vger.kernel.org" <keyrings@vger.kernel.org>,
	"linux-security-module@vger.kernel.org"
	<linux-security-module@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Keisuke Tsukuda <tkdkei@outlook.jp>
Subject: [PATCH] KEYS: trusted: caam: propagate protected key option parsing errors
Date: Tue, 24 Nov 2026 15:53:39 +0000	[thread overview]
Message-ID: <20261124155310.32044-1-tkdkei@outlook.jp> (raw)

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)


             reply	other threads:[~2026-11-24 15:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 15:53 Keisuke Tsukuda [this message]
2026-11-24 16:37 ` Serge E. Hallyn
2026-11-24 17:46 ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124155310.32044-1-tkdkei@outlook.jp \
    --to=tkdkei@outlook.jp \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=dhowells@redhat.com \
    --cc=jarkko@kernel.org \
    --cc=jmorris@namei.org \
    --cc=kernel@pengutronix.de \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®