* [PATCH] KEYS: trusted_tpm2: Only check options->keyhandle for ASN.1
@ 2024-05-25 12:36 Jarkko Sakkinen
2024-05-25 13:42 ` James Bottomley
0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Sakkinen @ 2024-05-25 12:36 UTC (permalink / raw)
To: linux-integrity
Cc: keyrings, James.Bottomley, Jarkko Sakkinen, stable, Mimi Zohar,
David Howells, Paul Moore, James Morris, Serge E. Hallyn,
linux-security-module, linux-kernel
tpm2_load_cmd incorrectly checks options->keyhandle also for the legacy
format, as also implied by the inline comment. Check options->keyhandle
when ASN.1 is loaded.
Cc: James Bottomey <James.Bottomley@HansenPartnership.com>
Cc: stable@vger.kernel.org # v5.13+
Fixes: f2219745250f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
security/keys/trusted-keys/trusted_tpm2.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
index 8b7dd73d94c1..4f8207bf52a7 100644
--- a/security/keys/trusted-keys/trusted_tpm2.c
+++ b/security/keys/trusted-keys/trusted_tpm2.c
@@ -400,12 +400,11 @@ static int tpm2_load_cmd(struct tpm_chip *chip,
/* old form */
blob = payload->blob;
payload->old_format = 1;
+ } else {
+ if (!options->keyhandle)
+ return -EINVAL;
}
- /* new format carries keyhandle but old format doesn't */
- if (!options->keyhandle)
- return -EINVAL;
-
/* must be big enough for at least the two be16 size counts */
if (payload->blob_len < 4)
return -EINVAL;
--
2.45.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KEYS: trusted_tpm2: Only check options->keyhandle for ASN.1
2024-05-25 12:36 [PATCH] KEYS: trusted_tpm2: Only check options->keyhandle for ASN.1 Jarkko Sakkinen
@ 2024-05-25 13:42 ` James Bottomley
2024-05-25 15:15 ` Jarkko Sakkinen
0 siblings, 1 reply; 3+ messages in thread
From: James Bottomley @ 2024-05-25 13:42 UTC (permalink / raw)
To: Jarkko Sakkinen, linux-integrity
Cc: keyrings, stable, Mimi Zohar, David Howells, Paul Moore,
James Morris, Serge E. Hallyn, linux-security-module,
linux-kernel
On Sat, 2024-05-25 at 15:36 +0300, Jarkko Sakkinen wrote:
> tpm2_load_cmd incorrectly checks options->keyhandle also for the
> legacy format, as also implied by the inline comment. Check
> options->keyhandle when ASN.1 is loaded.
No that's not right. keyhandle must be specified for the old format,
because it's just the two private/public blobs and doesn't know it's
parent. Since tpm2_key_decode() always places the ASN.1 parent into
options->keyhandle, the proposed new code is fully redundant (options-
>keyhandle must be non zero if the ASN.1 parsed correctly) but it loses
the check that the loader must specify it for the old format.
What the comment above the code you removed means is that the keyhandle
must be non zero here, either extracted from the ASN.1 for the new
format or specified on the command line for the old.
James
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KEYS: trusted_tpm2: Only check options->keyhandle for ASN.1
2024-05-25 13:42 ` James Bottomley
@ 2024-05-25 15:15 ` Jarkko Sakkinen
0 siblings, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2024-05-25 15:15 UTC (permalink / raw)
To: James Bottomley, linux-integrity
Cc: keyrings, stable, Mimi Zohar, David Howells, Paul Moore,
James Morris, Serge E. Hallyn, linux-security-module,
linux-kernel
On Sat May 25, 2024 at 4:42 PM EEST, James Bottomley wrote:
> On Sat, 2024-05-25 at 15:36 +0300, Jarkko Sakkinen wrote:
> > tpm2_load_cmd incorrectly checks options->keyhandle also for the
> > legacy format, as also implied by the inline comment. Check
> > options->keyhandle when ASN.1 is loaded.
>
> No that's not right. keyhandle must be specified for the old format,
> because it's just the two private/public blobs and doesn't know it's
> parent. Since tpm2_key_decode() always places the ASN.1 parent into
> options->keyhandle, the proposed new code is fully redundant (options-
> >keyhandle must be non zero if the ASN.1 parsed correctly) but it loses
> the check that the loader must specify it for the old format.
>
> What the comment above the code you removed means is that the keyhandle
> must be non zero here, either extracted from the ASN.1 for the new
> format or specified on the command line for the old.
My code change was plain direct to the word interpreation of the
comment.
So I just take the last paragraph of yours and instead fix the
misleading comment:
/*
* Keyhandle must be non zero here, either extracted from the ASN.1 for
* the new format or specified on the command line for the old.
*/
BR, Jarkko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-25 15:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-25 12:36 [PATCH] KEYS: trusted_tpm2: Only check options->keyhandle for ASN.1 Jarkko Sakkinen
2024-05-25 13:42 ` James Bottomley
2024-05-25 15:15 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).