The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/2] keys: trusted: tpm1: add bounds check in tpm_seal() before memcpy
@ 2026-08-25 18:29 sn0x-sharma
  2026-08-25 18:29 ` [PATCH 2/2] keys: trusted: tpm1: reject unauthenticated response tag in TSS_checkhmac1/2 sn0x-sharma
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: sn0x-sharma @ 2026-08-25 18:29 UTC (permalink / raw)
  To: jarkko
  Cc: James.Bottomley, zohar, dhowells, linux-integrity, keyrings,
	linux-kernel, security, w, sn0x-sharma

tpm_seal() computes storedsize from TPM response fields and passes
it directly to memcpy() into a MAX_BLOB_SIZE buffer without bounds
validation. A forged TPM response can set storedsize to 4086,
overflowing the 512-byte blob by 3574 bytes into adjacent slab
objects.

Add a check that storedsize does not exceed MAX_BLOB_SIZE before
the memcpy, returning -EINVAL on oversized responses.

Reported-by: sn0x-sharma <sanketsharmacsec@gmail.com>
Link: https://lore.kernel.org/linux-integrity/
Signed-off-by: sn0x-sharma <sanketsharmacsec@gmail.com>
---
 security/keys/trusted-keys/trusted_tpm1.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/security/keys/trusted-keys/trusted_tpm1.c b/security/keys/trusted-keys/trusted_tpm1.c
index 8f57c6111..d47cb7108 100644
--- a/security/keys/trusted-keys/trusted_tpm1.c
+++ b/security/keys/trusted-keys/trusted_tpm1.c
@@ -531,6 +531,10 @@ static int tpm_seal(struct tpm_buf *tb, uint16_t keytype,
 
 	/* copy the returned blob to caller */
 	if (!ret) {
+		if (storedsize > MAX_BLOB_SIZE) {
+			ret = -EINVAL;
+			goto out;
+		}
 		memcpy(blob, tb->data + TPM_DATA_OFFSET, storedsize);
 		*bloblen = storedsize;
 	}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-26  8:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25 18:29 [PATCH 1/2] keys: trusted: tpm1: add bounds check in tpm_seal() before memcpy sn0x-sharma
2026-08-25 18:29 ` [PATCH 2/2] keys: trusted: tpm1: reject unauthenticated response tag in TSS_checkhmac1/2 sn0x-sharma
2026-08-26  6:18 ` [PATCH 1/2] keys: trusted: tpm1: add bounds check in tpm_seal() before memcpy Greg KH
2026-08-26  8:04 ` [PATCH v2 " Sanket Sharma
2026-08-26  8:04   ` [PATCH v2 2/2] keys: trusted: tpm1: reject unauthenticated response tag in TSS_checkhmac1/2 Sanket Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox