multihit.rst 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. iTLB multihit
  2. =============
  3. iTLB multihit is an erratum where some processors may incur a machine check
  4. error, possibly resulting in an unrecoverable CPU lockup, when an
  5. instruction fetch hits multiple entries in the instruction TLB. This can
  6. occur when the page size is changed along with either the physical address
  7. or cache type. A malicious guest running on a virtualized system can
  8. exploit this erratum to perform a denial of service attack.
  9. Affected processors
  10. -------------------
  11. Variations of this erratum are present on most Intel Core and Xeon processor
  12. models. The erratum is not present on:
  13. - non-Intel processors
  14. - Some Atoms (Airmont, Bonnell, Goldmont, GoldmontPlus, Saltwell, Silvermont)
  15. - Intel processors that have the PSCHANGE_MC_NO bit set in the
  16. IA32_ARCH_CAPABILITIES MSR.
  17. Related CVEs
  18. ------------
  19. The following CVE entry is related to this issue:
  20. ============== =================================================
  21. CVE-2018-12207 Machine Check Error Avoidance on Page Size Change
  22. ============== =================================================
  23. Problem
  24. -------
  25. Privileged software, including OS and virtual machine managers (VMM), are in
  26. charge of memory management. A key component in memory management is the control
  27. of the page tables. Modern processors use virtual memory, a technique that creates
  28. the illusion of a very large memory for processors. This virtual space is split
  29. into pages of a given size. Page tables translate virtual addresses to physical
  30. addresses.
  31. To reduce latency when performing a virtual to physical address translation,
  32. processors include a structure, called TLB, that caches recent translations.
  33. There are separate TLBs for instruction (iTLB) and data (dTLB).
  34. Under this errata, instructions are fetched from a linear address translated
  35. using a 4 KB translation cached in the iTLB. Privileged software modifies the
  36. paging structure so that the same linear address using large page size (2 MB, 4
  37. MB, 1 GB) with a different physical address or memory type. After the page
  38. structure modification but before the software invalidates any iTLB entries for
  39. the linear address, a code fetch that happens on the same linear address may
  40. cause a machine-check error which can result in a system hang or shutdown.
  41. Attack scenarios
  42. ----------------
  43. Attacks against the iTLB multihit erratum can be mounted from malicious
  44. guests in a virtualized system.
  45. iTLB multihit system information
  46. --------------------------------
  47. The Linux kernel provides a sysfs interface to enumerate the current iTLB
  48. multihit status of the system:whether the system is vulnerable and which
  49. mitigations are active. The relevant sysfs file is:
  50. /sys/devices/system/cpu/vulnerabilities/itlb_multihit
  51. The possible values in this file are:
  52. .. list-table::
  53. * - Not affected
  54. - The processor is not vulnerable.
  55. * - KVM: Mitigation: Split huge pages
  56. - Software changes mitigate this issue.
  57. * - KVM: Vulnerable
  58. - The processor is vulnerable, but no mitigation enabled
  59. Enumeration of the erratum
  60. --------------------------------
  61. A new bit has been allocated in the IA32_ARCH_CAPABILITIES (PSCHANGE_MC_NO) msr
  62. and will be set on CPU's which are mitigated against this issue.
  63. ======================================= =========== ===============================
  64. IA32_ARCH_CAPABILITIES MSR Not present Possibly vulnerable,check model
  65. IA32_ARCH_CAPABILITIES[PSCHANGE_MC_NO] '0' Likely vulnerable,check model
  66. IA32_ARCH_CAPABILITIES[PSCHANGE_MC_NO] '1' Not vulnerable
  67. ======================================= =========== ===============================
  68. Mitigation mechanism
  69. -------------------------
  70. This erratum can be mitigated by restricting the use of large page sizes to
  71. non-executable pages. This forces all iTLB entries to be 4K, and removes
  72. the possibility of multiple hits.
  73. In order to mitigate the vulnerability, KVM initially marks all huge pages
  74. as non-executable. If the guest attempts to execute in one of those pages,
  75. the page is broken down into 4K pages, which are then marked executable.
  76. If EPT is disabled or not available on the host, KVM is in control of TLB
  77. flushes and the problematic situation cannot happen. However, the shadow
  78. EPT paging mechanism used by nested virtualization is vulnerable, because
  79. the nested guest can trigger multiple iTLB hits by modifying its own
  80. (non-nested) page tables. For simplicity, KVM will make large pages
  81. non-executable in all shadow paging modes.
  82. Mitigation control on the kernel command line and KVM - module parameter
  83. ------------------------------------------------------------------------
  84. The KVM hypervisor mitigation mechanism for marking huge pages as
  85. non-executable can be controlled with a module parameter "nx_huge_pages=".
  86. The kernel command line allows to control the iTLB multihit mitigations at
  87. boot time with the option "kvm.nx_huge_pages=".
  88. The valid arguments for these options are:
  89. ========== ================================================================
  90. force Mitigation is enabled. In this case, the mitigation implements
  91. non-executable huge pages in Linux kernel KVM module. All huge
  92. pages in the EPT are marked as non-executable.
  93. If a guest attempts to execute in one of those pages, the page is
  94. broken down into 4K pages, which are then marked executable.
  95. off Mitigation is disabled.
  96. auto Enable mitigation only if the platform is affected and the kernel
  97. was not booted with the "mitigations=off" command line parameter.
  98. This is the default option.
  99. ========== ================================================================
  100. Mitigation selection guide
  101. --------------------------
  102. 1. No virtualization in use
  103. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  104. The system is protected by the kernel unconditionally and no further
  105. action is required.
  106. 2. Virtualization with trusted guests
  107. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  108. If the guest comes from a trusted source, you may assume that the guest will
  109. not attempt to maliciously exploit these errata and no further action is
  110. required.
  111. 3. Virtualization with untrusted guests
  112. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  113. If the guest comes from an untrusted source, the guest host kernel will need
  114. to apply iTLB multihit mitigation via the kernel command line or kvm
  115. module parameter.