This library is mainly used by SMM Core to start performance logging to ensure that\r
SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase.\r
\r
+ Caution: This module requires additional review when modified.\r
+ This driver will have external input - performance data and communicate buffer in SMM mode.\r
+ This external input must be validated carefully to avoid security issue like\r
+ buffer overflow, integer overflow.\r
+\r
+ SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation.\r
+\r
Copyright (c) 2011 - 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
Communication service SMI Handler entry.\r
\r
This SMI handler provides services for the performance wrapper driver.\r
+ \r
+ Caution: This function may receive untrusted input.\r
+ Communicate buffer and buffer size are external input, so this function will do basic validation.\r
\r
@param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
@param[in] RegisterContext Points to an optional handler context which was specified when the\r
\r
GaugeEntryExArray = NULL;\r
\r
- ASSERT (CommBuffer != NULL);\r
+ //\r
+ // If input is invalid, stop processing this SMI\r
+ //\r
+ if (CommBuffer == NULL || CommBufferSize == NULL) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if(*CommBufferSize < sizeof (SMM_PERF_COMMUNICATE_EX)) {\r
+ return EFI_SUCCESS;\r
+ }\r
\r
+ if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {\r
+ DEBUG ((EFI_D_ERROR, "SMM communcation data buffer is in SMRAM!\n"));\r
+ return EFI_SUCCESS;\r
+ }\r
+ \r
SmmPerfCommData = (SMM_PERF_COMMUNICATE_EX *)CommBuffer;\r
\r
switch (SmmPerfCommData->Function) {\r
//\r
DataSize = SmmPerfCommData->NumberOfEntries * sizeof(GAUGE_DATA_ENTRY_EX);\r
if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)SmmPerfCommData->GaugeDataEx, DataSize)) {\r
- DEBUG ((EFI_D_ERROR, "Smm Performance Data buffer is in SMRAM!\n"));\r
+ DEBUG ((EFI_D_ERROR, "SMM Performance Data buffer is in SMRAM!\n"));\r
Status = EFI_ACCESS_DENIED;\r
- break ;\r
+ break;\r
}\r
\r
GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);\r
break;\r
\r
default:\r
- ASSERT (FALSE);\r
Status = EFI_UNSUPPORTED;\r
}\r
\r
+\r
SmmPerfCommData->ReturnStatus = Status;\r
+ \r
return EFI_SUCCESS;\r
}\r
\r
\r
This SMI handler provides services for the performance wrapper driver.\r
\r
+ Caution: This function may receive untrusted input.\r
+ Communicate buffer and buffer size are external input, so this function will do basic validation.\r
+\r
@param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
@param[in] RegisterContext Points to an optional handler context which was specified when the\r
handler was registered.\r
UINTN DataSize;\r
UINTN Index;\r
UINTN LogEntryKey;\r
-\r
+ \r
GaugeEntryExArray = NULL;\r
\r
- ASSERT (CommBuffer != NULL);\r
+ //\r
+ // If input is invalid, stop processing this SMI\r
+ //\r
+ if (CommBuffer == NULL || CommBufferSize == NULL) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if(*CommBufferSize < sizeof (SMM_PERF_COMMUNICATE)) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {\r
+ DEBUG ((EFI_D_ERROR, "SMM communcation data buffer is in SMRAM!\n"));\r
+ return EFI_SUCCESS;\r
+ }\r
\r
SmmPerfCommData = (SMM_PERF_COMMUNICATE *)CommBuffer;\r
\r
//\r
DataSize = SmmPerfCommData->NumberOfEntries * sizeof(GAUGE_DATA_ENTRY);\r
if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)SmmPerfCommData->GaugeData, DataSize)) {\r
- DEBUG ((EFI_D_ERROR, "Smm Performance Data buffer is in SMRAM!\n"));\r
+ DEBUG ((EFI_D_ERROR, "SMM Performance Data buffer is in SMRAM!\n"));\r
Status = EFI_ACCESS_DENIED;\r
- break ;\r
+ break;\r
}\r
\r
GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);\r
break;\r
\r
default:\r
- ASSERT (FALSE);\r
Status = EFI_UNSUPPORTED;\r
}\r
\r
+\r
SmmPerfCommData->ReturnStatus = Status;\r
+ \r
return EFI_SUCCESS;\r
}\r
\r
This module registers report status code listener to collect performance data\r
for SMM driver boot records and S3 Suspend Performance Record.\r
\r
+ Caution: This module requires additional review when modified.\r
+ This driver will have external input - communicate buffer in SMM mode.\r
+ This external input must be validated carefully to avoid security issue like\r
+ buffer overflow, integer overflow.\r
+\r
+ FpdtSmiHandler() will receive untrusted input and do basic validation.\r
+\r
Copyright (c) 2011 - 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
\r
This SMI handler provides services for report SMM boot records. \r
\r
+ Caution: This function may receive untrusted input.\r
+ Communicate buffer and buffer size are external input, so this function will do basic validation.\r
+\r
@param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
@param[in] RegisterContext Points to an optional handler context which was specified when the\r
handler was registered.\r
be conveyed from a non-SMM environment into an SMM environment.\r
@param[in, out] CommBufferSize The size of the CommBuffer.\r
\r
- @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers should still be called.\r
- @retval EFI_INVALID_PARAMETER The interrupt parameter is not valid. \r
- @retval EFI_ACCESS_DENIED The interrupt buffer can't be written. \r
- @retval EFI_UNSUPPORTED The interrupt is not supported. \r
+ @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers \r
+ should still be called.\r
+ @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should \r
+ still be called.\r
+ @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still \r
+ be called.\r
+ @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.\r
+\r
**/\r
EFI_STATUS\r
EFIAPI\r
{\r
EFI_STATUS Status;\r
SMM_BOOT_RECORD_COMMUNICATE *SmmCommData;\r
+\r
+ //\r
+ // If input is invalid, stop processing this SMI\r
+ //\r
+ if (CommBuffer == NULL || CommBufferSize == NULL) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if(*CommBufferSize < sizeof (SMM_BOOT_RECORD_COMMUNICATE)) {\r
+ return EFI_SUCCESS;\r
+ }\r
\r
- ASSERT (CommBuffer != NULL);\r
- if (CommBuffer == NULL || *CommBufferSize < sizeof (SMM_BOOT_RECORD_COMMUNICATE)) {\r
- return EFI_INVALID_PARAMETER;\r
+ if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {\r
+ DEBUG ((EFI_D_ERROR, "SMM communication data buffer is in SMRAM!\n"));\r
+ return EFI_SUCCESS;\r
}\r
\r
- Status = EFI_SUCCESS;\r
SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE*)CommBuffer;\r
\r
+ Status = EFI_SUCCESS;\r
+\r
switch (SmmCommData->Function) {\r
case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE :\r
SmmCommData->BootRecordSize = mBootRecordSize;\r
Status = EFI_INVALID_PARAMETER;\r
break;\r
} \r
- \r
+\r
//\r
// Sanity check\r
//\r
SmmCommData->BootRecordSize = mBootRecordSize;\r
if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)SmmCommData->BootRecordData, mBootRecordSize)) {\r
- DEBUG ((EFI_D_ERROR, "Smm Data buffer is in SMRAM!\n"));\r
+ DEBUG ((EFI_D_ERROR, "SMM Data buffer is in SMRAM!\n"));\r
Status = EFI_ACCESS_DENIED;\r
break;\r
}\r
break;\r
\r
default:\r
- ASSERT (FALSE);\r
Status = EFI_UNSUPPORTED;\r
}\r
\r
SmmCommData->ReturnStatus = Status;\r
+ \r
return EFI_SUCCESS;\r
}\r
\r