X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=SecurityPkg%2FLibrary%2FDxeTpmMeasureBootLib%2FDxeTpmMeasureBootLib.c;h=466a74ef093feb93031eda4d27c6891b88338abd;hp=f3e486eadc7a97bb9d129c0ec7b40c63abe9296d;hb=6f785cfcc304c48ec04e542ee429df95e7b51bc5;hpb=6dbdb1914d293d9abd378bf4f035d6f38809eaf3 diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c index f3e486eadc..466a74ef09 100644 --- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c +++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c @@ -15,7 +15,7 @@ TcgMeasureGptTable() function will receive untrusted GPT partition table, and parse partition data carefully. -Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
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 @@ -31,10 +31,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include -#include +#include #include #include @@ -59,7 +58,7 @@ UINTN mImageSize; // Measured FV handle cache // EFI_HANDLE mCacheMeasuredHandle = NULL; -UINT32 *mGuidHobData = NULL; +MEASURED_HOB_DATA *mMeasuredHobData = NULL; /** Reads contents of a PE/COFF image in memory buffer. @@ -372,7 +371,9 @@ TcgMeasurePeImage ( ImageLoad->ImageLengthInMemory = ImageSize; ImageLoad->ImageLinkTimeAddress = LinkTimeBase; ImageLoad->LengthOfDevicePath = FilePathSize; - CopyMem (ImageLoad->DevicePath, FilePath, FilePathSize); + if ((FilePath != NULL) && (FilePathSize != 0)) { + CopyMem (ImageLoad->DevicePath, FilePath, FilePathSize); + } // // Check PE/COFF image @@ -664,6 +665,14 @@ TcgMeasurePeImage ( &EventNumber, &EventLogLastEntry ); + if (Status == EFI_OUT_OF_RESOURCES) { + // + // Out of resource here means the image is hashed and its result is extended to PCR. + // But the event log cann't be saved since log area is full. + // Just return EFI_SUCCESS in order not to block the image load. + // + Status = EFI_SUCCESS; + } Finish: FreePool (TcgEvent); @@ -740,7 +749,6 @@ DxeTpmMeasureBootHandler ( PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol; EFI_PHYSICAL_ADDRESS FvAddress; - EFI_PLATFORM_FIRMWARE_BLOB *TrustedFvBuf; UINT32 Index; Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **) &TcgProtocol); @@ -760,7 +768,7 @@ DxeTpmMeasureBootHandler ( &EventLogLocation, &EventLogLastEntry ); - if (EFI_ERROR (Status) || ProtocolCapability.TPMDeactivatedFlag) { + if (EFI_ERROR (Status) || ProtocolCapability.TPMDeactivatedFlag || (!ProtocolCapability.TPMPresentFlag)) { // // TPM device doesn't work or activate. // @@ -848,14 +856,14 @@ DxeTpmMeasureBootHandler ( return EFI_SUCCESS; } // - // The PE image from untrusted Firmware volume need be measured - // The PE image from trusted Firmware volume will be mearsured according to policy below. - // if it is driver, do not measure + // The PE image from unmeasured Firmware volume need be measured + // The PE image from measured Firmware volume will be mearsured according to policy below. + // If it is driver, do not measure // If it is application, still measure. // ApplicationRequired = TRUE; - if (mCacheMeasuredHandle != Handle && mGuidHobData != NULL) { + if (mCacheMeasuredHandle != Handle && mMeasuredHobData != NULL) { // // Search for Root FV of this PE image // @@ -877,11 +885,10 @@ DxeTpmMeasureBootHandler ( return Status; } - TrustedFvBuf = (EFI_PLATFORM_FIRMWARE_BLOB *)(mGuidHobData + 1); ApplicationRequired = FALSE; - for (Index = 0; Index < *mGuidHobData; Index++) { - if(TrustedFvBuf[Index].BlobBase == FvAddress) { + for (Index = 0; Index < mMeasuredHobData->Num; Index++) { + if(mMeasuredHobData->MeasuredFvBuf[Index].BlobBase == FvAddress) { // // Cache measured FV for next measurement // @@ -934,21 +941,14 @@ DxeTpmMeasureBootHandler ( // DEBUG_CODE_BEGIN (); CHAR16 *ToText; - EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText; - Status = gBS->LocateProtocol ( - &gEfiDevicePathToTextProtocolGuid, - NULL, - (VOID **) &DevPathToText - ); - if (!EFI_ERROR (Status)) { - ToText = DevPathToText->ConvertDevicePathToText ( - DevicePathNode, - FALSE, - TRUE - ); - if (ToText != NULL) { - DEBUG ((DEBUG_INFO, "The measured image path is %s.\n", ToText)); - } + ToText = ConvertDevicePathToText ( + DevicePathNode, + FALSE, + TRUE + ); + if (ToText != NULL) { + DEBUG ((DEBUG_INFO, "The measured image path is %s.\n", ToText)); + FreePool (ToText); } DEBUG_CODE_END (); @@ -996,10 +996,10 @@ DxeTpmMeasureBootLibConstructor ( GuidHob = NULL; - GuidHob = GetFirstGuidHob (&gTrustedFvHobGuid); + GuidHob = GetFirstGuidHob (&gMeasuredFvHobGuid); if (GuidHob != NULL) { - mGuidHobData = GET_GUID_HOB_DATA (GuidHob); + mMeasuredHobData = GET_GUID_HOB_DATA (GuidHob); } return RegisterSecurity2Handler (