15999bbe7SThomas GleixnerMDS - Microarchitectural Data Sampling 25999bbe7SThomas Gleixner====================================== 35999bbe7SThomas Gleixner 45999bbe7SThomas GleixnerMicroarchitectural Data Sampling is a hardware vulnerability which allows 55999bbe7SThomas Gleixnerunprivileged speculative access to data which is available in various CPU 65999bbe7SThomas Gleixnerinternal buffers. 75999bbe7SThomas Gleixner 85999bbe7SThomas GleixnerAffected processors 95999bbe7SThomas Gleixner------------------- 105999bbe7SThomas Gleixner 115999bbe7SThomas GleixnerThis vulnerability affects a wide range of Intel processors. The 125999bbe7SThomas Gleixnervulnerability is not present on: 135999bbe7SThomas Gleixner 145999bbe7SThomas Gleixner - Processors from AMD, Centaur and other non Intel vendors 155999bbe7SThomas Gleixner 165999bbe7SThomas Gleixner - Older processor models, where the CPU family is < 6 175999bbe7SThomas Gleixner 185999bbe7SThomas Gleixner - Some Atoms (Bonnell, Saltwell, Goldmont, GoldmontPlus) 195999bbe7SThomas Gleixner 205999bbe7SThomas Gleixner - Intel processors which have the ARCH_CAP_MDS_NO bit set in the 215999bbe7SThomas Gleixner IA32_ARCH_CAPABILITIES MSR. 225999bbe7SThomas Gleixner 235999bbe7SThomas GleixnerWhether a processor is affected or not can be read out from the MDS 245999bbe7SThomas Gleixnervulnerability file in sysfs. See :ref:`mds_sys_info`. 255999bbe7SThomas Gleixner 265999bbe7SThomas GleixnerNot all processors are affected by all variants of MDS, but the mitigation 275999bbe7SThomas Gleixneris identical for all of them so the kernel treats them as a single 285999bbe7SThomas Gleixnervulnerability. 295999bbe7SThomas Gleixner 305999bbe7SThomas GleixnerRelated CVEs 315999bbe7SThomas Gleixner------------ 325999bbe7SThomas Gleixner 335999bbe7SThomas GleixnerThe following CVE entries are related to the MDS vulnerability: 345999bbe7SThomas Gleixner 35e672f8bfSspeck for Pawan Gupta ============== ===== =================================================== 365999bbe7SThomas Gleixner CVE-2018-12126 MSBDS Microarchitectural Store Buffer Data Sampling 375999bbe7SThomas Gleixner CVE-2018-12130 MFBDS Microarchitectural Fill Buffer Data Sampling 385999bbe7SThomas Gleixner CVE-2018-12127 MLPDS Microarchitectural Load Port Data Sampling 39e672f8bfSspeck for Pawan Gupta CVE-2019-11091 MDSUM Microarchitectural Data Sampling Uncacheable Memory 40e672f8bfSspeck for Pawan Gupta ============== ===== =================================================== 415999bbe7SThomas Gleixner 425999bbe7SThomas GleixnerProblem 435999bbe7SThomas Gleixner------- 445999bbe7SThomas Gleixner 455999bbe7SThomas GleixnerWhen performing store, load, L1 refill operations, processors write data 465999bbe7SThomas Gleixnerinto temporary microarchitectural structures (buffers). The data in the 475999bbe7SThomas Gleixnerbuffer can be forwarded to load operations as an optimization. 485999bbe7SThomas Gleixner 495999bbe7SThomas GleixnerUnder certain conditions, usually a fault/assist caused by a load 505999bbe7SThomas Gleixneroperation, data unrelated to the load memory address can be speculatively 515999bbe7SThomas Gleixnerforwarded from the buffers. Because the load operation causes a fault or 525999bbe7SThomas Gleixnerassist and its result will be discarded, the forwarded data will not cause 535999bbe7SThomas Gleixnerincorrect program execution or state changes. But a malicious operation 545999bbe7SThomas Gleixnermay be able to forward this speculative data to a disclosure gadget which 555999bbe7SThomas Gleixnerallows in turn to infer the value via a cache side channel attack. 565999bbe7SThomas Gleixner 575999bbe7SThomas GleixnerBecause the buffers are potentially shared between Hyper-Threads cross 585999bbe7SThomas GleixnerHyper-Thread attacks are possible. 595999bbe7SThomas Gleixner 605999bbe7SThomas GleixnerDeeper technical information is available in the MDS specific x86 615999bbe7SThomas Gleixnerarchitecture section: :ref:`Documentation/x86/mds.rst <mds>`. 625999bbe7SThomas Gleixner 635999bbe7SThomas Gleixner 645999bbe7SThomas GleixnerAttack scenarios 655999bbe7SThomas Gleixner---------------- 665999bbe7SThomas Gleixner 67*dbeb56feSRandy DunlapAttacks against the MDS vulnerabilities can be mounted from malicious non- 68*dbeb56feSRandy Dunlapprivileged user space applications running on hosts or guest. Malicious 695999bbe7SThomas Gleixnerguest OSes can obviously mount attacks as well. 705999bbe7SThomas Gleixner 715999bbe7SThomas GleixnerContrary to other speculation based vulnerabilities the MDS vulnerability 725999bbe7SThomas Gleixnerdoes not allow the attacker to control the memory target address. As a 735999bbe7SThomas Gleixnerconsequence the attacks are purely sampling based, but as demonstrated with 745999bbe7SThomas Gleixnerthe TLBleed attack samples can be postprocessed successfully. 755999bbe7SThomas Gleixner 765999bbe7SThomas GleixnerWeb-Browsers 775999bbe7SThomas Gleixner^^^^^^^^^^^^ 785999bbe7SThomas Gleixner 795999bbe7SThomas Gleixner It's unclear whether attacks through Web-Browsers are possible at 805999bbe7SThomas Gleixner all. The exploitation through Java-Script is considered very unlikely, 815999bbe7SThomas Gleixner but other widely used web technologies like Webassembly could possibly be 825999bbe7SThomas Gleixner abused. 835999bbe7SThomas Gleixner 845999bbe7SThomas Gleixner 855999bbe7SThomas Gleixner.. _mds_sys_info: 865999bbe7SThomas Gleixner 875999bbe7SThomas GleixnerMDS system information 885999bbe7SThomas Gleixner----------------------- 895999bbe7SThomas Gleixner 905999bbe7SThomas GleixnerThe Linux kernel provides a sysfs interface to enumerate the current MDS 915999bbe7SThomas Gleixnerstatus of the system: whether the system is vulnerable, and which 925999bbe7SThomas Gleixnermitigations are active. The relevant sysfs file is: 935999bbe7SThomas Gleixner 945999bbe7SThomas Gleixner/sys/devices/system/cpu/vulnerabilities/mds 955999bbe7SThomas Gleixner 965999bbe7SThomas GleixnerThe possible values in this file are: 975999bbe7SThomas Gleixner 98ea01668fSTyler Hicks .. list-table:: 995999bbe7SThomas Gleixner 100ea01668fSTyler Hicks * - 'Not affected' 101ea01668fSTyler Hicks - The processor is not vulnerable 102ea01668fSTyler Hicks * - 'Vulnerable' 103ea01668fSTyler Hicks - The processor is vulnerable, but no mitigation enabled 104ea01668fSTyler Hicks * - 'Vulnerable: Clear CPU buffers attempted, no microcode' 105ea01668fSTyler Hicks - The processor is vulnerable but microcode is not updated. 1065999bbe7SThomas Gleixner 107ea01668fSTyler Hicks The mitigation is enabled on a best effort basis. See :ref:`vmwerv` 108ea01668fSTyler Hicks * - 'Mitigation: Clear CPU buffers' 109ea01668fSTyler Hicks - The processor is vulnerable and the CPU buffer clearing mitigation is 1105999bbe7SThomas Gleixner enabled. 1115999bbe7SThomas Gleixner 1125999bbe7SThomas GleixnerIf the processor is vulnerable then the following information is appended 1135999bbe7SThomas Gleixnerto the above information: 1145999bbe7SThomas Gleixner 1155999bbe7SThomas Gleixner ======================== ============================================ 1165999bbe7SThomas Gleixner 'SMT vulnerable' SMT is enabled 1175999bbe7SThomas Gleixner 'SMT mitigated' SMT is enabled and mitigated 1185999bbe7SThomas Gleixner 'SMT disabled' SMT is disabled 1195999bbe7SThomas Gleixner 'SMT Host state unknown' Kernel runs in a VM, Host SMT state unknown 1205999bbe7SThomas Gleixner ======================== ============================================ 1215999bbe7SThomas Gleixner 1225999bbe7SThomas Gleixner.. _vmwerv: 1235999bbe7SThomas Gleixner 1245999bbe7SThomas GleixnerBest effort mitigation mode 1255999bbe7SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1265999bbe7SThomas Gleixner 1275999bbe7SThomas Gleixner If the processor is vulnerable, but the availability of the microcode based 1285999bbe7SThomas Gleixner mitigation mechanism is not advertised via CPUID the kernel selects a best 1295999bbe7SThomas Gleixner effort mitigation mode. This mode invokes the mitigation instructions 1305999bbe7SThomas Gleixner without a guarantee that they clear the CPU buffers. 1315999bbe7SThomas Gleixner 1325999bbe7SThomas Gleixner This is done to address virtualization scenarios where the host has the 1335999bbe7SThomas Gleixner microcode update applied, but the hypervisor is not yet updated to expose 1345999bbe7SThomas Gleixner the CPUID to the guest. If the host has updated microcode the protection 1355999bbe7SThomas Gleixner takes effect otherwise a few cpu cycles are wasted pointlessly. 1365999bbe7SThomas Gleixner 1375999bbe7SThomas Gleixner The state in the mds sysfs file reflects this situation accordingly. 1385999bbe7SThomas Gleixner 1395999bbe7SThomas Gleixner 1405999bbe7SThomas GleixnerMitigation mechanism 1415999bbe7SThomas Gleixner------------------------- 1425999bbe7SThomas Gleixner 1435999bbe7SThomas GleixnerThe kernel detects the affected CPUs and the presence of the microcode 1445999bbe7SThomas Gleixnerwhich is required. 1455999bbe7SThomas Gleixner 1465999bbe7SThomas GleixnerIf a CPU is affected and the microcode is available, then the kernel 1475999bbe7SThomas Gleixnerenables the mitigation by default. The mitigation can be controlled at boot 1485999bbe7SThomas Gleixnertime via a kernel command line option. See 1495999bbe7SThomas Gleixner:ref:`mds_mitigation_control_command_line`. 1505999bbe7SThomas Gleixner 1515999bbe7SThomas Gleixner.. _cpu_buffer_clear: 1525999bbe7SThomas Gleixner 1535999bbe7SThomas GleixnerCPU buffer clearing 1545999bbe7SThomas Gleixner^^^^^^^^^^^^^^^^^^^ 1555999bbe7SThomas Gleixner 1565999bbe7SThomas Gleixner The mitigation for MDS clears the affected CPU buffers on return to user 1575999bbe7SThomas Gleixner space and when entering a guest. 1585999bbe7SThomas Gleixner 1595999bbe7SThomas Gleixner If SMT is enabled it also clears the buffers on idle entry when the CPU 1605999bbe7SThomas Gleixner is only affected by MSBDS and not any other MDS variant, because the 1615999bbe7SThomas Gleixner other variants cannot be protected against cross Hyper-Thread attacks. 1625999bbe7SThomas Gleixner 1635999bbe7SThomas Gleixner For CPUs which are only affected by MSBDS the user space, guest and idle 1645999bbe7SThomas Gleixner transition mitigations are sufficient and SMT is not affected. 1655999bbe7SThomas Gleixner 1665999bbe7SThomas Gleixner.. _virt_mechanism: 1675999bbe7SThomas Gleixner 1685999bbe7SThomas GleixnerVirtualization mitigation 1695999bbe7SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^ 1705999bbe7SThomas Gleixner 1715999bbe7SThomas Gleixner The protection for host to guest transition depends on the L1TF 1725999bbe7SThomas Gleixner vulnerability of the CPU: 1735999bbe7SThomas Gleixner 1745999bbe7SThomas Gleixner - CPU is affected by L1TF: 1755999bbe7SThomas Gleixner 1765999bbe7SThomas Gleixner If the L1D flush mitigation is enabled and up to date microcode is 1775999bbe7SThomas Gleixner available, the L1D flush mitigation is automatically protecting the 1785999bbe7SThomas Gleixner guest transition. 1795999bbe7SThomas Gleixner 1805999bbe7SThomas Gleixner If the L1D flush mitigation is disabled then the MDS mitigation is 1815999bbe7SThomas Gleixner invoked explicit when the host MDS mitigation is enabled. 1825999bbe7SThomas Gleixner 1835999bbe7SThomas Gleixner For details on L1TF and virtualization see: 1845999bbe7SThomas Gleixner :ref:`Documentation/admin-guide/hw-vuln//l1tf.rst <mitigation_control_kvm>`. 1855999bbe7SThomas Gleixner 1865999bbe7SThomas Gleixner - CPU is not affected by L1TF: 1875999bbe7SThomas Gleixner 1885999bbe7SThomas Gleixner CPU buffers are flushed before entering the guest when the host MDS 1895999bbe7SThomas Gleixner mitigation is enabled. 1905999bbe7SThomas Gleixner 1915999bbe7SThomas Gleixner The resulting MDS protection matrix for the host to guest transition: 1925999bbe7SThomas Gleixner 1935999bbe7SThomas Gleixner ============ ===== ============= ============ ================= 1945999bbe7SThomas Gleixner L1TF MDS VMX-L1FLUSH Host MDS MDS-State 1955999bbe7SThomas Gleixner 1965999bbe7SThomas Gleixner Don't care No Don't care N/A Not affected 1975999bbe7SThomas Gleixner 1985999bbe7SThomas Gleixner Yes Yes Disabled Off Vulnerable 1995999bbe7SThomas Gleixner 2005999bbe7SThomas Gleixner Yes Yes Disabled Full Mitigated 2015999bbe7SThomas Gleixner 2025999bbe7SThomas Gleixner Yes Yes Enabled Don't care Mitigated 2035999bbe7SThomas Gleixner 2045999bbe7SThomas Gleixner No Yes N/A Off Vulnerable 2055999bbe7SThomas Gleixner 2065999bbe7SThomas Gleixner No Yes N/A Full Mitigated 2075999bbe7SThomas Gleixner ============ ===== ============= ============ ================= 2085999bbe7SThomas Gleixner 2095999bbe7SThomas Gleixner This only covers the host to guest transition, i.e. prevents leakage from 2105999bbe7SThomas Gleixner host to guest, but does not protect the guest internally. Guests need to 2115999bbe7SThomas Gleixner have their own protections. 2125999bbe7SThomas Gleixner 2135999bbe7SThomas Gleixner.. _xeon_phi: 2145999bbe7SThomas Gleixner 2155999bbe7SThomas GleixnerXEON PHI specific considerations 2165999bbe7SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2175999bbe7SThomas Gleixner 2185999bbe7SThomas Gleixner The XEON PHI processor family is affected by MSBDS which can be exploited 2195999bbe7SThomas Gleixner cross Hyper-Threads when entering idle states. Some XEON PHI variants allow 2205999bbe7SThomas Gleixner to use MWAIT in user space (Ring 3) which opens an potential attack vector 2215999bbe7SThomas Gleixner for malicious user space. The exposure can be disabled on the kernel 2225999bbe7SThomas Gleixner command line with the 'ring3mwait=disable' command line option. 2235999bbe7SThomas Gleixner 2245999bbe7SThomas Gleixner XEON PHI is not affected by the other MDS variants and MSBDS is mitigated 2255999bbe7SThomas Gleixner before the CPU enters a idle state. As XEON PHI is not affected by L1TF 2265999bbe7SThomas Gleixner either disabling SMT is not required for full protection. 2275999bbe7SThomas Gleixner 2285999bbe7SThomas Gleixner.. _mds_smt_control: 2295999bbe7SThomas Gleixner 2305999bbe7SThomas GleixnerSMT control 2315999bbe7SThomas Gleixner^^^^^^^^^^^ 2325999bbe7SThomas Gleixner 2335999bbe7SThomas Gleixner All MDS variants except MSBDS can be attacked cross Hyper-Threads. That 2345999bbe7SThomas Gleixner means on CPUs which are affected by MFBDS or MLPDS it is necessary to 2355999bbe7SThomas Gleixner disable SMT for full protection. These are most of the affected CPUs; the 2365999bbe7SThomas Gleixner exception is XEON PHI, see :ref:`xeon_phi`. 2375999bbe7SThomas Gleixner 2385999bbe7SThomas Gleixner Disabling SMT can have a significant performance impact, but the impact 2395999bbe7SThomas Gleixner depends on the type of workloads. 2405999bbe7SThomas Gleixner 2415999bbe7SThomas Gleixner See the relevant chapter in the L1TF mitigation documentation for details: 2425999bbe7SThomas Gleixner :ref:`Documentation/admin-guide/hw-vuln/l1tf.rst <smt_control>`. 2435999bbe7SThomas Gleixner 2445999bbe7SThomas Gleixner 2455999bbe7SThomas Gleixner.. _mds_mitigation_control_command_line: 2465999bbe7SThomas Gleixner 2475999bbe7SThomas GleixnerMitigation control on the kernel command line 2485999bbe7SThomas Gleixner--------------------------------------------- 2495999bbe7SThomas Gleixner 2505999bbe7SThomas GleixnerThe kernel command line allows to control the MDS mitigations at boot 2515999bbe7SThomas Gleixnertime with the option "mds=". The valid arguments for this option are: 2525999bbe7SThomas Gleixner 2535999bbe7SThomas Gleixner ============ ============================================================= 2545999bbe7SThomas Gleixner full If the CPU is vulnerable, enable all available mitigations 2555999bbe7SThomas Gleixner for the MDS vulnerability, CPU buffer clearing on exit to 2565999bbe7SThomas Gleixner userspace and when entering a VM. Idle transitions are 2575999bbe7SThomas Gleixner protected as well if SMT is enabled. 2585999bbe7SThomas Gleixner 2595999bbe7SThomas Gleixner It does not automatically disable SMT. 2605999bbe7SThomas Gleixner 261d71eb0ceSJosh Poimboeuf full,nosmt The same as mds=full, with SMT disabled on vulnerable 262d71eb0ceSJosh Poimboeuf CPUs. This is the complete mitigation. 263d71eb0ceSJosh Poimboeuf 2645999bbe7SThomas Gleixner off Disables MDS mitigations completely. 2655999bbe7SThomas Gleixner 2665999bbe7SThomas Gleixner ============ ============================================================= 2675999bbe7SThomas Gleixner 26864870ed1SWaiman LongNot specifying this option is equivalent to "mds=full". For processors 26964870ed1SWaiman Longthat are affected by both TAA (TSX Asynchronous Abort) and MDS, 27064870ed1SWaiman Longspecifying just "mds=off" without an accompanying "tsx_async_abort=off" 27164870ed1SWaiman Longwill have no effect as the same mitigation is used for both 27264870ed1SWaiman Longvulnerabilities. 2735999bbe7SThomas Gleixner 2745999bbe7SThomas GleixnerMitigation selection guide 2755999bbe7SThomas Gleixner-------------------------- 2765999bbe7SThomas Gleixner 2775999bbe7SThomas Gleixner1. Trusted userspace 2785999bbe7SThomas Gleixner^^^^^^^^^^^^^^^^^^^^ 2795999bbe7SThomas Gleixner 2805999bbe7SThomas Gleixner If all userspace applications are from a trusted source and do not 2815999bbe7SThomas Gleixner execute untrusted code which is supplied externally, then the mitigation 2825999bbe7SThomas Gleixner can be disabled. 2835999bbe7SThomas Gleixner 2845999bbe7SThomas Gleixner 2855999bbe7SThomas Gleixner2. Virtualization with trusted guests 2865999bbe7SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2875999bbe7SThomas Gleixner 2885999bbe7SThomas Gleixner The same considerations as above versus trusted user space apply. 2895999bbe7SThomas Gleixner 2905999bbe7SThomas Gleixner3. Virtualization with untrusted guests 2915999bbe7SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2925999bbe7SThomas Gleixner 2935999bbe7SThomas Gleixner The protection depends on the state of the L1TF mitigations. 2945999bbe7SThomas Gleixner See :ref:`virt_mechanism`. 2955999bbe7SThomas Gleixner 2965999bbe7SThomas Gleixner If the MDS mitigation is enabled and SMT is disabled, guest to host and 2975999bbe7SThomas Gleixner guest to guest attacks are prevented. 2985999bbe7SThomas Gleixner 2995999bbe7SThomas Gleixner.. _mds_default_mitigations: 3005999bbe7SThomas Gleixner 3015999bbe7SThomas GleixnerDefault mitigations 3025999bbe7SThomas Gleixner------------------- 3035999bbe7SThomas Gleixner 3045999bbe7SThomas Gleixner The kernel default mitigations for vulnerable processors are: 3055999bbe7SThomas Gleixner 3065999bbe7SThomas Gleixner - Enable CPU buffer clearing 3075999bbe7SThomas Gleixner 3085999bbe7SThomas Gleixner The kernel does not by default enforce the disabling of SMT, which leaves 3095999bbe7SThomas Gleixner SMT systems vulnerable when running untrusted code. The same rationale as 3105999bbe7SThomas Gleixner for L1TF applies. 3115999bbe7SThomas Gleixner See :ref:`Documentation/admin-guide/hw-vuln//l1tf.rst <default_mitigations>`. 312