Skip to contentSkip to conversation

efi_loader: fix possible buffer overflow

PATCH New Masahisa Kojima 3 participants 3 messages Apr 14, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi_loader: fix possible buffer overflow

Variable "final" will have SHA512 digest, but currently the array size is not sufficient. Let's fix it.

---
 lib/efi_loader/efi_tcg2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_tcg2.c +1 -1
index ed86a220fb..d5eca68769 100644
@@ -515,7 +515,7 @@ static efi_status_t tcg2_create_digest(const u8 *input, u32 length,
 	sha1_context ctx;
 	sha256_context ctx_256;
 	sha512_context ctx_512;
-	u8 final[TPM2_ALG_SHA512];
+	u8 final[TPM2_SHA512_DIGEST_SIZE];
 	efi_status_t ret;
 	u32 active;
 	int i;
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 efi_loader: fix possible buffer overflow

Quoted 24 lines · Masahisa Kojima

Variable "final" will have SHA512 digest, but currently the array size is not sufficient. Let's fix it.

---
 lib/efi_loader/efi_tcg2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_tcg2.c +1 -1
index ed86a220fb..d5eca68769 100644
@@ -515,7 +515,7 @@ static efi_status_t tcg2_create_digest(const u8 *input, u32 length,
 	sha1_context ctx;
 	sha256_context ctx_256;
 	sha512_context ctx_512;
-	u8 final[TPM2_ALG_SHA512];
+	u8 final[TPM2_SHA512_DIGEST_SIZE];
 	efi_status_t ret;
 	u32 active;
 	int i;
Signature · 1 line
2.17.1

Thanks!

#2 lore raw

PATCH 1/1 efi_loader: fix possible buffer overflow

Quoted 28 lines · Ilias Apalodimas
Quoted 22 lines · Masahisa Kojima

Variable "final" will have SHA512 digest, but currently the array size is not sufficient. Let's fix it.

---
  lib/efi_loader/efi_tcg2.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_tcg2.c +1 -2
index ed86a220fb..d5eca68769 100644
@@ -515,7 +515,7 @@ static efi_status_t tcg2_create_digest(const u8 *input, u32 length,
  	sha1_context ctx;
  	sha256_context ctx_256;
  	sha512_context ctx_512;
-	u8 final[TPM2_ALG_SHA512];
+	u8 final[TPM2_SHA512_DIGEST_SIZE];
  	efi_status_t ret;
  	u32 active;
  	int i;
--
Quoted 2 lines

2.17.1

Thanks!

Quoted 2 lines

I have queued the patch for my next pull request.