No description
Find a file
Hao Wu 9077599e73 MdeModulePkg/SmmCorePerfLib: [CVE-2017-5753] Fix bounds check bypass
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1194

Speculative execution is used by processor to avoid having to wait for
data to arrive from memory, or for previous operations to finish, the
processor may speculate as to what will be executed.

If the speculation is incorrect, the speculatively executed instructions
might leave hints such as which memory locations have been brought into
cache. Malicious actors can use the bounds check bypass method (code
gadgets with controlled external inputs) to infer data values that have
been used in speculative operations to reveal secrets which should not
otherwise be accessed.

This commit will focus on the SMI handler(s) registered within the
SmmCorePerformanceLib and insert AsmLfence API to mitigate the bounds
check bypass issue.

For SMI handler SmmPerformanceHandlerEx():

Under "case SMM_PERF_FUNCTION_GET_GAUGE_DATA :",
'SmmPerfCommData->LogEntryKey' can be a potential cross boundary access of
the 'CommBuffer' (controlled external inputs) during speculative
execution. This cross boundary access is then assign to parameter
'LogEntryKey'. And the value of 'LogEntryKey' can be inferred by code:

  CopyMem (
    (UINT8 *) &GaugeDataEx[Index],
    (UINT8 *) &GaugeEntryExArray[LogEntryKey++],
    sizeof (GAUGE_DATA_ENTRY_EX)
    );

One can observe which part of the content within 'GaugeEntryExArray' was
brought into cache to possibly reveal the value of 'LogEntryKey'.

Hence, this commit adds a AsmLfence() after the boundary/range checks of
'CommBuffer' to prevent the speculative execution.

And there is 1 similar case for SMI handler SmmPerformanceHandler() as
well. This commit also handles it.

A more detailed explanation of the purpose of commit is under the
'Bounds check bypass mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

And the document at:
https://software.intel.com/security-software-guidance/api-app/sites/default/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-11-21 09:37:31 +08:00
AppPkg AppPkg: Add the Arithchk utility and clean up some build problems. 2014-09-09 22:37:02 +00:00
ArmPkg ArmPsciResetSystemLib: read PSCI method in constructor 2014-09-16 00:51:17 +00:00
ArmPlatformPkg ArmPlatformPkg: separate PlatformPei and PlatformPeiLib 2014-09-16 00:56:50 +00:00
BaseTools BaseTools/Bin: Add edk2-BaseTools-win32 repo version info in externals.txt 2016-07-28 09:01:22 +08:00
BeagleBoardPkg ARM Packages: Replace tabs by spaces for indentation 2014-08-26 10:14:17 +00:00
Conf Adding top-level Conf directory for next generation of EDK II build infrastructure tools. 2007-06-20 19:33:23 +00:00
CryptoPkg CryptoPkg BaseCryptLib: Avoid passing NULL ptr to function BN_bn2bin() 2016-07-05 08:59:37 +08:00
DuetPkg Sync patch r16218 from main trunk. 2014-11-25 05:12:54 +00:00
EdkCompatibilityPkg EdkCompatibilityPkg: Add PersistentMemory definition 2015-04-29 05:51:51 +00:00
EdkShellBinPkg EDK II Contributions.txt: Note acceptable contribution licenses 2014-08-25 23:10:18 +00:00
EdkShellPkg EDK II Contributions.txt: Note acceptable contribution licenses 2014-08-25 23:10:18 +00:00
EmbeddedPkg EmbeddedPkg/Lan9118Dxe: Fixed typo 2014-09-16 00:55:47 +00:00
EmulatorPkg EmulatorPkg: Unix: Use XCODE5 and lldb if Xcode 5 is detected 2014-08-29 18:58:36 +00:00
FatBinPkg Check in binaries for EBC/IA32/X64/IPF built from MdePkg and BaseTools (r16700), FatPkg (r93). 2015-02-11 08:11:44 +00:00
IntelFrameworkModulePkg IntelFrameworkModulePkg: Fix a memory leak bug in BdsDxe driver. 2016-06-20 11:17:14 +08:00
IntelFrameworkPkg IntelFrameworkPkg: fix mixed dos and linux EOL format issue 2015-02-03 07:12:39 +00:00
IntelFspPkg Copy head revision r18124 from main trunk. 2015-08-25 06:05:40 +00:00
IntelFspWrapperPkg FspNotifyDxe need handle >4G memory. 2015-08-25 06:35:09 +00:00
MdeModulePkg MdeModulePkg/SmmCorePerfLib: [CVE-2017-5753] Fix bounds check bypass 2018-11-21 09:37:31 +08:00
MdePkg MdePkg/BaseLib: Add new AsmLfence API 2018-11-15 13:13:44 +08:00
NetworkPkg NetworkPkg: Replace ASSERT with error return code in PXE driver. 2016-12-19 09:09:35 +08:00
Nt32Pkg EDK II Contributions.txt: Note acceptable contribution licenses 2014-08-25 23:10:18 +00:00
Omap35xxPkg ARM Packages: Replace tabs by spaces for indentation 2014-08-26 10:14:17 +00:00
OptionRomPkg EDK II Contributions.txt: Note acceptable contribution licenses 2014-08-25 23:10:18 +00:00
OvmfPkg OvmfPkg: Fix the build.sh shebang line to avoid depending on location of bash 2015-07-09 01:54:38 +00:00
PcAtChipsetPkg PcAtChipsetPkg: Update BaseAcpiTimerLib 2015-08-31 08:43:07 +00:00
PerformancePkg Performance: Refine the format of INF files. 2015-02-13 05:28:14 +00:00
SecurityPkg SecurityPkg/VariableAuth: [CVE-2017-5753] Fix bounds check bypass 2018-11-15 15:40:32 +08:00
ShellBinPkg ShellBinPkg: Ia32/X64 Shell binary update. 2015-04-30 05:54:26 +00:00
ShellPkg ShellPkg: Fix typo of 'determines' in ShellPkg. 2015-07-09 01:51:04 +00:00
SourceLevelDebugPkg Size optimization for those modules only invoke SaveAndSetDebugTimerInterrupt(). 2015-03-05 02:42:21 +00:00
StdLib StdLib: Fix some build problems and obscure bugs. 2014-09-11 21:42:26 +00:00
StdLibPrivateInternalFiles EDK II Contributions.txt: Note acceptable contribution licenses 2014-08-25 23:10:18 +00:00
UefiCpuPkg Refine the format of PCD in INF files for UefiCpuPkg. 2015-02-13 05:22:58 +00:00
UnixPkg UnixPkg: Remove UnixPkg files (It is replaced by EmulatorPkg) 2013-07-29 21:09:55 +00:00
Vlv2DeviceRefCodePkg Vlv2TbltDevicePkg/Vlv2DeviceRefCodePkg: 2016-01-21 07:11:59 +00:00
Vlv2TbltDevicePkg Vlv2TbltDevicePkg: Update the BiosID to V0.90. 2016-01-28 01:12:59 +00:00
BuildNotes2.txt Update to new SVN URL in readme.txt 2013-06-08 05:26:39 +00:00
Edk2Setup.bat Updated version, missed the last two commits and to add the SVN Revision property (last part of the version value). 2014-08-22 16:08:47 +00:00
edksetup.bat Sync patch r16277 from main trunk. 2014-11-25 07:12:28 +00:00
edksetup.sh edksetup.sh: Ensure that WORKSPACE points to the top of an edk2 checkout 2014-07-28 17:37:40 +00:00