]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/TcgDxe/TcgDxe.c
Fix TCG protocol TcgDxeHashLogExtendEvent and TcgDxeLogEvent SDL issue
[mirror_edk2.git] / SecurityPkg / Tcg / TcgDxe / TcgDxe.c
index 75c6a8978f45c4ac1778802a76d5b29e57866748..5ef34d0ba20418faa3ef6498f5cdfff2e1cf6e10 100644 (file)
@@ -1,6 +1,13 @@
 /** @file  \r
   This module implements TCG EFI Protocol.\r
-  \r
\r
+Caution: This module requires additional review when modified.\r
+This driver will have external input - TcgDxePassThroughToTpm\r
+This external input must be validated carefully to avoid security issue like\r
+buffer overflow, integer overflow.\r
+\r
+TcgDxePassThroughToTpm() will receive untrusted input and do basic validation.\r
+\r
 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials \r
 are licensed and made available under the terms and conditions of the BSD License \r
@@ -345,6 +352,10 @@ TcgDxeLogEvent (
 {\r
   TCG_DXE_DATA  *TcgData;\r
 \r
+  if (TCGLogData == NULL){\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   TcgData = TCG_DXE_DATA_FROM_THIS (This);\r
   \r
   if (TcgData->BsCap.TPMDeactivatedFlag) {\r
@@ -384,6 +395,13 @@ TcgDxePassThroughToTpm (
 {\r
   TCG_DXE_DATA                      *TcgData;\r
 \r
+  if (TpmInputParameterBlock == NULL || \r
+      TpmOutputParameterBlock == NULL || \r
+      TpmInputParameterBlockSize == 0 ||\r
+      TpmOutputParameterBlockSize == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   TcgData = TCG_DXE_DATA_FROM_THIS (This);\r
 \r
   return TisPcExecute (\r
@@ -424,7 +442,11 @@ TcgDxeHashLogExtendEventI (
 {\r
   EFI_STATUS                        Status;\r
 \r
-  if (HashDataLen > 0) {\r
+  if (HashData == NULL && HashDataLen > 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (HashDataLen > 0 || HashData != NULL) {\r
     Status = TpmCommHashAll (\r
                HashData,\r
                (UINTN) HashDataLen,\r
@@ -484,6 +506,10 @@ TcgDxeHashLogExtendEvent (
 {\r
   TCG_DXE_DATA  *TcgData;\r
 \r
+  if (TCGLogData == NULL || EventLogLastEntry == NULL){\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   TcgData = TCG_DXE_DATA_FROM_THIS (This);\r
   \r
   if (TcgData->BsCap.TPMDeactivatedFlag) {\r