* [PATCH] KEYS: trusted: Change -EINVAL to -E2BIG
@ 2024-05-29 15:02 Jarkko Sakkinen
0 siblings, 0 replies; only message in thread
From: Jarkko Sakkinen @ 2024-05-29 15:02 UTC (permalink / raw)
To: Herbert Xu
Cc: linux-integrity, keyrings, Andreas.Fuchs, James Prestwood,
David Woodhouse, Eric Biggers, James Bottomley, linux-crypto,
Stefan Berger, Jarkko Sakkinen, James Bottomley, Mimi Zohar,
David Howells, Paul Moore, James Morris, Serge E. Hallyn,
linux-security-module, linux-kernel
Report -E2BIG instead of -EINVAL when too large size for the key blob is
requested. By filtering these errors from other invalid data, this will
help distinguish the overflows.
Link: https://lore.kernel.org/keyrings/D1M4GRF0RL2W.3QHTBXZWNW9RW@kernel.org/
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
I don't think this is a fix and neither needs to be backported but makes
sense for upcoming versions. Sending as a separate patch from the TPM2
asymmetric keys series.
security/keys/trusted-keys/trusted_tpm2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
index 8b7dd73d94c1..06c8fa7b21ae 100644
--- a/security/keys/trusted-keys/trusted_tpm2.c
+++ b/security/keys/trusted-keys/trusted_tpm2.c
@@ -122,7 +122,7 @@ static int tpm2_key_decode(struct trusted_key_payload *payload,
return ret;
if (ctx.priv_len + ctx.pub_len > MAX_BLOB_SIZE)
- return -EINVAL;
+ return -E2BIG;
blob = kmalloc(ctx.priv_len + ctx.pub_len + 4, GFP_KERNEL);
if (!blob)
--
2.45.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-05-29 15:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 15:02 [PATCH] KEYS: trusted: Change -EINVAL to -E2BIG 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).