diff options
author | Zhang, Chao B <chao.b.zhang@intel.com> | 2018-03-20 16:32:11 +0800 |
---|---|---|
committer | Zhang, Chao B <chao.b.zhang@intel.com> | 2018-03-21 16:43:34 +0800 |
commit | dd577319e83d13a7ab46ffdccb6635281d2ca9e5 (patch) | |
tree | bf46fa68e9e5edfb5c6c9e64793e820eb247fedc /SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c | |
parent | ca2c8725c4894c55ffd7ce091e5f0c4ef9c794ed (diff) | |
download | edk2-dd577319e83d13a7ab46ffdccb6635281d2ca9e5.tar.gz edk2-dd577319e83d13a7ab46ffdccb6635281d2ca9e5.tar.bz2 edk2-dd577319e83d13a7ab46ffdccb6635281d2ca9e5.zip |
SecurityPkg Tpm2CommandLib: Fix TPM2.0 response memory overflow
TPM2.0 command lib always assumes TPM device and transmission channel can
respond correctly. But it is not true when communication channel is exploited
and wrong data is spoofed. Add more logic to prohibit memory overflow attack.
Cc: Long Qin <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
Diffstat (limited to 'SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c')
-rw-r--r-- | SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c index 305b6f2078..90877768d3 100644 --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c @@ -1,7 +1,7 @@ /** @file
Implement TPM2 Sequences related command.
-Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -375,6 +375,11 @@ Tpm2EventSequenceComplete ( // count
Results->count = SwapBytes32(ReadUnaligned32 ((UINT32 *)BufferPtr));
+ if (Results->count > HASH_COUNT) {
+ DEBUG ((DEBUG_ERROR, "Tpm2EventSequenceComplete - Results->count error %x\n", Results->count));
+ return EFI_DEVICE_ERROR;
+ }
+
BufferPtr += sizeof(UINT32);
for (Index = 0; Index < Results->count; Index++) {
@@ -496,6 +501,11 @@ Tpm2SequenceComplete ( // digestSize
Result->size = SwapBytes16(ReadUnaligned16 ((UINT16 *)BufferPtr));
+ if (Result->size > sizeof(TPMU_HA)){
+ DEBUG ((DEBUG_ERROR, "Tpm2SequenceComplete - Result->size error %x\n", Result->size));
+ return EFI_DEVICE_ERROR;
+ }
+
BufferPtr += sizeof(UINT16);
CopyMem(
|