mds.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. MDS - Microarchitectural Data Sampling
  2. ======================================
  3. Microarchitectural Data Sampling is a hardware vulnerability which allows
  4. unprivileged speculative access to data which is available in various CPU
  5. internal buffers.
  6. Affected processors
  7. -------------------
  8. This vulnerability affects a wide range of Intel processors. The
  9. vulnerability is not present on:
  10. - Processors from AMD, Centaur and other non Intel vendors
  11. - Older processor models, where the CPU family is < 6
  12. - Some Atoms (Bonnell, Saltwell, Goldmont, GoldmontPlus)
  13. - Intel processors which have the ARCH_CAP_MDS_NO bit set in the
  14. IA32_ARCH_CAPABILITIES MSR.
  15. Whether a processor is affected or not can be read out from the MDS
  16. vulnerability file in sysfs. See :ref:`mds_sys_info`.
  17. Not all processors are affected by all variants of MDS, but the mitigation
  18. is identical for all of them so the kernel treats them as a single
  19. vulnerability.
  20. Related CVEs
  21. ------------
  22. The following CVE entries are related to the MDS vulnerability:
  23. ============== ===== ===================================================
  24. CVE-2018-12126 MSBDS Microarchitectural Store Buffer Data Sampling
  25. CVE-2018-12130 MFBDS Microarchitectural Fill Buffer Data Sampling
  26. CVE-2018-12127 MLPDS Microarchitectural Load Port Data Sampling
  27. CVE-2019-11091 MDSUM Microarchitectural Data Sampling Uncacheable Memory
  28. ============== ===== ===================================================
  29. Problem
  30. -------
  31. When performing store, load, L1 refill operations, processors write data
  32. into temporary microarchitectural structures (buffers). The data in the
  33. buffer can be forwarded to load operations as an optimization.
  34. Under certain conditions, usually a fault/assist caused by a load
  35. operation, data unrelated to the load memory address can be speculatively
  36. forwarded from the buffers. Because the load operation causes a fault or
  37. assist and its result will be discarded, the forwarded data will not cause
  38. incorrect program execution or state changes. But a malicious operation
  39. may be able to forward this speculative data to a disclosure gadget which
  40. allows in turn to infer the value via a cache side channel attack.
  41. Because the buffers are potentially shared between Hyper-Threads cross
  42. Hyper-Thread attacks are possible.
  43. Deeper technical information is available in the MDS specific x86
  44. architecture section: :ref:`Documentation/x86/mds.rst <mds>`.
  45. Attack scenarios
  46. ----------------
  47. Attacks against the MDS vulnerabilities can be mounted from malicious non
  48. priviledged user space applications running on hosts or guest. Malicious
  49. guest OSes can obviously mount attacks as well.
  50. Contrary to other speculation based vulnerabilities the MDS vulnerability
  51. does not allow the attacker to control the memory target address. As a
  52. consequence the attacks are purely sampling based, but as demonstrated with
  53. the TLBleed attack samples can be postprocessed successfully.
  54. Web-Browsers
  55. ^^^^^^^^^^^^
  56. It's unclear whether attacks through Web-Browsers are possible at
  57. all. The exploitation through Java-Script is considered very unlikely,
  58. but other widely used web technologies like Webassembly could possibly be
  59. abused.
  60. .. _mds_sys_info:
  61. MDS system information
  62. -----------------------
  63. The Linux kernel provides a sysfs interface to enumerate the current MDS
  64. status of the system: whether the system is vulnerable, and which
  65. mitigations are active. The relevant sysfs file is:
  66. /sys/devices/system/cpu/vulnerabilities/mds
  67. The possible values in this file are:
  68. .. list-table::
  69. * - 'Not affected'
  70. - The processor is not vulnerable
  71. * - 'Vulnerable'
  72. - The processor is vulnerable, but no mitigation enabled
  73. * - 'Vulnerable: Clear CPU buffers attempted, no microcode'
  74. - The processor is vulnerable but microcode is not updated.
  75. The mitigation is enabled on a best effort basis. See :ref:`vmwerv`
  76. * - 'Mitigation: Clear CPU buffers'
  77. - The processor is vulnerable and the CPU buffer clearing mitigation is
  78. enabled.
  79. If the processor is vulnerable then the following information is appended
  80. to the above information:
  81. ======================== ============================================
  82. 'SMT vulnerable' SMT is enabled
  83. 'SMT mitigated' SMT is enabled and mitigated
  84. 'SMT disabled' SMT is disabled
  85. 'SMT Host state unknown' Kernel runs in a VM, Host SMT state unknown
  86. ======================== ============================================
  87. .. _vmwerv:
  88. Best effort mitigation mode
  89. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  90. If the processor is vulnerable, but the availability of the microcode based
  91. mitigation mechanism is not advertised via CPUID the kernel selects a best
  92. effort mitigation mode. This mode invokes the mitigation instructions
  93. without a guarantee that they clear the CPU buffers.
  94. This is done to address virtualization scenarios where the host has the
  95. microcode update applied, but the hypervisor is not yet updated to expose
  96. the CPUID to the guest. If the host has updated microcode the protection
  97. takes effect otherwise a few cpu cycles are wasted pointlessly.
  98. The state in the mds sysfs file reflects this situation accordingly.
  99. Mitigation mechanism
  100. -------------------------
  101. The kernel detects the affected CPUs and the presence of the microcode
  102. which is required.
  103. If a CPU is affected and the microcode is available, then the kernel
  104. enables the mitigation by default. The mitigation can be controlled at boot
  105. time via a kernel command line option. See
  106. :ref:`mds_mitigation_control_command_line`.
  107. .. _cpu_buffer_clear:
  108. CPU buffer clearing
  109. ^^^^^^^^^^^^^^^^^^^
  110. The mitigation for MDS clears the affected CPU buffers on return to user
  111. space and when entering a guest.
  112. If SMT is enabled it also clears the buffers on idle entry when the CPU
  113. is only affected by MSBDS and not any other MDS variant, because the
  114. other variants cannot be protected against cross Hyper-Thread attacks.
  115. For CPUs which are only affected by MSBDS the user space, guest and idle
  116. transition mitigations are sufficient and SMT is not affected.
  117. .. _virt_mechanism:
  118. Virtualization mitigation
  119. ^^^^^^^^^^^^^^^^^^^^^^^^^
  120. The protection for host to guest transition depends on the L1TF
  121. vulnerability of the CPU:
  122. - CPU is affected by L1TF:
  123. If the L1D flush mitigation is enabled and up to date microcode is
  124. available, the L1D flush mitigation is automatically protecting the
  125. guest transition.
  126. If the L1D flush mitigation is disabled then the MDS mitigation is
  127. invoked explicit when the host MDS mitigation is enabled.
  128. For details on L1TF and virtualization see:
  129. :ref:`Documentation/admin-guide/hw-vuln//l1tf.rst <mitigation_control_kvm>`.
  130. - CPU is not affected by L1TF:
  131. CPU buffers are flushed before entering the guest when the host MDS
  132. mitigation is enabled.
  133. The resulting MDS protection matrix for the host to guest transition:
  134. ============ ===== ============= ============ =================
  135. L1TF MDS VMX-L1FLUSH Host MDS MDS-State
  136. Don't care No Don't care N/A Not affected
  137. Yes Yes Disabled Off Vulnerable
  138. Yes Yes Disabled Full Mitigated
  139. Yes Yes Enabled Don't care Mitigated
  140. No Yes N/A Off Vulnerable
  141. No Yes N/A Full Mitigated
  142. ============ ===== ============= ============ =================
  143. This only covers the host to guest transition, i.e. prevents leakage from
  144. host to guest, but does not protect the guest internally. Guests need to
  145. have their own protections.
  146. .. _xeon_phi:
  147. XEON PHI specific considerations
  148. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  149. The XEON PHI processor family is affected by MSBDS which can be exploited
  150. cross Hyper-Threads when entering idle states. Some XEON PHI variants allow
  151. to use MWAIT in user space (Ring 3) which opens an potential attack vector
  152. for malicious user space. The exposure can be disabled on the kernel
  153. command line with the 'ring3mwait=disable' command line option.
  154. XEON PHI is not affected by the other MDS variants and MSBDS is mitigated
  155. before the CPU enters a idle state. As XEON PHI is not affected by L1TF
  156. either disabling SMT is not required for full protection.
  157. .. _mds_smt_control:
  158. SMT control
  159. ^^^^^^^^^^^
  160. All MDS variants except MSBDS can be attacked cross Hyper-Threads. That
  161. means on CPUs which are affected by MFBDS or MLPDS it is necessary to
  162. disable SMT for full protection. These are most of the affected CPUs; the
  163. exception is XEON PHI, see :ref:`xeon_phi`.
  164. Disabling SMT can have a significant performance impact, but the impact
  165. depends on the type of workloads.
  166. See the relevant chapter in the L1TF mitigation documentation for details:
  167. :ref:`Documentation/admin-guide/hw-vuln/l1tf.rst <smt_control>`.
  168. .. _mds_mitigation_control_command_line:
  169. Mitigation control on the kernel command line
  170. ---------------------------------------------
  171. The kernel command line allows to control the MDS mitigations at boot
  172. time with the option "mds=". The valid arguments for this option are:
  173. ============ =============================================================
  174. full If the CPU is vulnerable, enable all available mitigations
  175. for the MDS vulnerability, CPU buffer clearing on exit to
  176. userspace and when entering a VM. Idle transitions are
  177. protected as well if SMT is enabled.
  178. It does not automatically disable SMT.
  179. full,nosmt The same as mds=full, with SMT disabled on vulnerable
  180. CPUs. This is the complete mitigation.
  181. off Disables MDS mitigations completely.
  182. ============ =============================================================
  183. Not specifying this option is equivalent to "mds=full". For processors
  184. that are affected by both TAA (TSX Asynchronous Abort) and MDS,
  185. specifying just "mds=off" without an accompanying "tsx_async_abort=off"
  186. will have no effect as the same mitigation is used for both
  187. vulnerabilities.
  188. Mitigation selection guide
  189. --------------------------
  190. 1. Trusted userspace
  191. ^^^^^^^^^^^^^^^^^^^^
  192. If all userspace applications are from a trusted source and do not
  193. execute untrusted code which is supplied externally, then the mitigation
  194. can be disabled.
  195. 2. Virtualization with trusted guests
  196. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  197. The same considerations as above versus trusted user space apply.
  198. 3. Virtualization with untrusted guests
  199. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  200. The protection depends on the state of the L1TF mitigations.
  201. See :ref:`virt_mechanism`.
  202. If the MDS mitigation is enabled and SMT is disabled, guest to host and
  203. guest to guest attacks are prevented.
  204. .. _mds_default_mitigations:
  205. Default mitigations
  206. -------------------
  207. The kernel default mitigations for vulnerable processors are:
  208. - Enable CPU buffer clearing
  209. The kernel does not by default enforce the disabling of SMT, which leaves
  210. SMT systems vulnerable when running untrusted code. The same rationale as
  211. for L1TF applies.
  212. See :ref:`Documentation/admin-guide/hw-vuln//l1tf.rst <default_mitigations>`.