Revision: 16796
http://sourceforge.net/p/edk2/code/16796
Author: vanjeff
Date: 2015-02-06 06:37:59 +0000 (Fri, 06 Feb 2015)
Log Message:
-----------
Use SmmMemLib to check communication buffer.
(Sync patch r16695 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <[email protected]>
Reviewed-by: "Gao, Liming" <[email protected]>
Reviewed-by: "Fan, Jeff" <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/16695
Modified Paths:
--------------
branches/UDK2014.SP1/SecurityPkg/SecurityPkg.dsc
branches/UDK2014.SP1/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
branches/UDK2014.SP1/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
Modified: branches/UDK2014.SP1/SecurityPkg/SecurityPkg.dsc
===================================================================
--- branches/UDK2014.SP1/SecurityPkg/SecurityPkg.dsc 2015-02-06 06:37:55 UTC
(rev 16795)
+++ branches/UDK2014.SP1/SecurityPkg/SecurityPkg.dsc 2015-02-06 06:37:59 UTC
(rev 16796)
@@ -112,6 +112,7 @@
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
+ SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
Modified:
branches/UDK2014.SP1/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
===================================================================
---
branches/UDK2014.SP1/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
2015-02-06 06:37:55 UTC (rev 16795)
+++
branches/UDK2014.SP1/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
2015-02-06 06:37:59 UTC (rev 16796)
@@ -32,14 +32,12 @@
#include <Protocol/SmmEndOfDxe.h>
#include <Library/SmmServicesTableLib.h>
+#include <Library/SmmMemLib.h>
#include <Guid/AuthenticatedVariableFormat.h>
#include <Guid/SmmVariableCommon.h>
#include "Variable.h"
-EFI_SMRAM_DESCRIPTOR *mSmramRanges;
-UINTN mSmramRangeCount;
-
extern VARIABLE_INFO_ENTRY *gVariableInfo;
EFI_HANDLE mSmmVariableHandle =
NULL;
EFI_HANDLE mVariableHandle =
NULL;
@@ -133,60 +131,6 @@
}
/**
- This function check if the address is in SMRAM.
-
- @param Buffer the buffer address to be checked.
- @param Length the buffer length to be checked.
-
- @retval TRUE this address is in SMRAM.
- @retval FALSE this address is NOT in SMRAM.
-**/
-BOOLEAN
-InternalIsAddressInSmram (
- IN EFI_PHYSICAL_ADDRESS Buffer,
- IN UINT64 Length
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < mSmramRangeCount; Index ++) {
- if (((Buffer >= mSmramRanges[Index].CpuStart) && (Buffer <
mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)) ||
- ((mSmramRanges[Index].CpuStart >= Buffer) &&
(mSmramRanges[Index].CpuStart < Buffer + Length))) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-/**
- This function check if the address refered by Buffer and Length is valid.
-
- @param Buffer the buffer address to be checked.
- @param Length the buffer length to be checked.
-
- @retval TRUE this address is valid.
- @retval FALSE this address is NOT valid.
-**/
-BOOLEAN
-InternalIsAddressValid (
- IN UINTN Buffer,
- IN UINTN Length
- )
-{
- if (Buffer > (MAX_ADDRESS - Length)) {
- //
- // Overflow happen
- //
- return FALSE;
- }
- if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length))
{
- return FALSE;
- }
- return TRUE;
-}
-
-/**
Initializes a basic mutual exclusion lock.
This function initializes a basic mutual exclusion lock to the released
state
@@ -544,7 +488,7 @@
return EFI_SUCCESS;
}
- if (!InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {
DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer in
SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
@@ -732,7 +676,7 @@
// It is covered by previous CommBuffer check
//
- if (InternalIsAddressInSmram
((EFI_PHYSICAL_ADDRESS)(UINTN)CommBufferSize, sizeof(UINTN))) {
+ if (!SmmIsBufferOutsideSmmValid
((EFI_PHYSICAL_ADDRESS)(UINTN)CommBufferSize, sizeof(UINTN))) {
DEBUG ((EFI_D_ERROR, "GetStatistics: SMM communication buffer in
SMRAM!\n"));
Status = EFI_ACCESS_DENIED;
goto EXIT;
@@ -892,8 +836,6 @@
EFI_STATUS Status;
EFI_HANDLE VariableHandle;
VOID *SmmFtwRegistration;
- EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
- UINTN Size;
VOID *SmmEndOfDxeRegistration;
//
@@ -914,28 +856,6 @@
);
ASSERT_EFI_ERROR (Status);
- //
- // Get SMRAM information
- //
- Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID
**)&SmmAccess);
- ASSERT_EFI_ERROR (Status);
-
- Size = 0;
- Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);
-
- Status = gSmst->SmmAllocatePool (
- EfiRuntimeServicesData,
- Size,
- (VOID **)&mSmramRanges
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);
- ASSERT_EFI_ERROR (Status);
-
- mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
-
mVariableBufferPayloadSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32
(PcdMaxHardwareErrorVariableSize)) +
OFFSET_OF
(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - sizeof (VARIABLE_HEADER);
Modified:
branches/UDK2014.SP1/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
===================================================================
---
branches/UDK2014.SP1/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
2015-02-06 06:37:55 UTC (rev 16795)
+++
branches/UDK2014.SP1/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
2015-02-06 06:37:59 UTC (rev 16796)
@@ -72,6 +72,7 @@
BaseCryptLib
PlatformSecureLib
HobLib
+ SmmMemLib
[Protocols]
gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits