UefiCpuPkg/PiSmmCpuDxeSmm: [CVE-2017-5753] Fix bounds check bypass


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.

It is possible for SMI handler(s) to call EFI_SMM_CPU_PROTOCOL service
ReadSaveState() and use the content in the 'CommBuffer' (controlled
external inputs) as the 'CpuIndex'. So this commit will insert AsmLfence
API to mitigate the bounds check bypass issue within SmmReadSaveState().

For SmmReadSaveState():

The 'CpuIndex' will be passed into function ReadSaveStateRegister(). And
then in to ReadSaveStateRegisterByIndex().

With the call:
ReadSaveStateRegisterByIndex (

The 'IoMisc' can be a cross boundary access during speculative execution.
Later, 'IoMisc' is used as the index to access buffers 'mSmmCpuIoWidth'
and 'mSmmCpuIoType'. One can observe which part of the content within
those buffers was brought into cache to possibly reveal the value of

Hence, this commit adds a AsmLfence() after the check of 'CpuIndex'
within function SmmReadSaveState() to prevent the speculative execution.

A more detailed explanation of the purpose of commit is under the
'Bounds check bypass mitigation' section of the below link:

And the document at:

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 5b02be4d9a234d80c7578fc3a0c789d22ce83f38)
1 file changed
tree: db7bf760032dda687392b154b7680135fee235df
  1. .gitignore
  2. .gitmodules
  3. AppPkg/
  4. ArmPkg/
  5. ArmPlatformPkg/
  6. ArmVirtPkg/
  7. BaseTools/
  8. BeagleBoardPkg/
  9. BuildNotes2.txt
  10. Conf/
  11. Contributions.txt
  12. CorebootModulePkg/
  13. CorebootPayloadPkg/
  14. CryptoPkg/
  15. DuetPkg/
  16. EdkCompatibilityPkg/
  17. EdkShellBinPkg/
  18. EdkShellPkg/
  19. EmbeddedPkg/
  20. EmulatorPkg/
  21. FatBinPkg/
  22. FatPkg/
  23. FmpDevicePkg/
  24. IntelFrameworkModulePkg/
  25. IntelFrameworkPkg/
  26. IntelFsp2Pkg/
  27. IntelFsp2WrapperPkg/
  28. IntelFspPkg/
  29. IntelFspWrapperPkg/
  30. IntelSiliconPkg/
  31. License.txt
  32. Maintainers.txt
  33. MdeModulePkg/
  34. MdePkg/
  35. NetworkPkg/
  36. Nt32Pkg/
  37. Omap35xxPkg/
  38. OptionRomPkg/
  39. OvmfPkg/
  40. PcAtChipsetPkg/
  41. QuarkPlatformPkg/
  42. QuarkSocPkg/
  43. Readme.md
  44. SecurityPkg/
  45. ShellBinPkg/
  46. ShellPkg/
  47. SignedCapsulePkg/
  48. SourceLevelDebugPkg/
  49. StdLib/
  50. StdLibPrivateInternalFiles/
  51. UefiCpuPkg/
  52. UnixPkg/
  53. Vlv2DeviceRefCodePkg/
  54. Vlv2TbltDevicePkg/
  55. edksetup.bat
  56. edksetup.sh

EDK II Project

A modern, feature-rich, cross-platform firmware development environment for the UEFI and PI specifications from www.uefi.org.

Contributions to the EDK II open source project are covered by the TianoCore Contribution Agreement 1.1

The majority of the content in the EDK II open source project uses a BSD 2-Clause License. The EDK II open source project contains the following components that are covered by additional licenses:

The EDK II Project is composed of packages. The maintainers for each package are listed in Maintainers.txt.