gather_data_sampling.rst 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. .. SPDX-License-Identifier: GPL-2.0
  2. GDS - Gather Data Sampling
  3. ==========================
  4. Gather Data Sampling is a hardware vulnerability which allows unprivileged
  5. speculative access to data which was previously stored in vector registers.
  6. Problem
  7. -------
  8. When a gather instruction performs loads from memory, different data elements
  9. are merged into the destination vector register. However, when a gather
  10. instruction that is transiently executed encounters a fault, stale data from
  11. architectural or internal vector registers may get transiently forwarded to the
  12. destination vector register instead. This will allow a malicious attacker to
  13. infer stale data using typical side channel techniques like cache timing
  14. attacks. GDS is a purely sampling-based attack.
  15. The attacker uses gather instructions to infer the stale vector register data.
  16. The victim does not need to do anything special other than use the vector
  17. registers. The victim does not need to use gather instructions to be
  18. vulnerable.
  19. Because the buffers are shared between Hyper-Threads cross Hyper-Thread attacks
  20. are possible.
  21. Attack scenarios
  22. ----------------
  23. Without mitigation, GDS can infer stale data across virtually all
  24. permission boundaries:
  25. Non-enclaves can infer SGX enclave data
  26. Userspace can infer kernel data
  27. Guests can infer data from hosts
  28. Guest can infer guest from other guests
  29. Users can infer data from other users
  30. Because of this, it is important to ensure that the mitigation stays enabled in
  31. lower-privilege contexts like guests and when running outside SGX enclaves.
  32. The hardware enforces the mitigation for SGX. Likewise, VMMs should ensure
  33. that guests are not allowed to disable the GDS mitigation. If a host erred and
  34. allowed this, a guest could theoretically disable GDS mitigation, mount an
  35. attack, and re-enable it.
  36. Mitigation mechanism
  37. --------------------
  38. This issue is mitigated in microcode. The microcode defines the following new
  39. bits:
  40. ================================ === ============================
  41. IA32_ARCH_CAPABILITIES[GDS_CTRL] R/O Enumerates GDS vulnerability
  42. and mitigation support.
  43. IA32_ARCH_CAPABILITIES[GDS_NO] R/O Processor is not vulnerable.
  44. IA32_MCU_OPT_CTRL[GDS_MITG_DIS] R/W Disables the mitigation
  45. 0 by default.
  46. IA32_MCU_OPT_CTRL[GDS_MITG_LOCK] R/W Locks GDS_MITG_DIS=0. Writes
  47. to GDS_MITG_DIS are ignored
  48. Can't be cleared once set.
  49. ================================ === ============================
  50. GDS can also be mitigated on systems that don't have updated microcode by
  51. disabling AVX. This can be done by setting gather_data_sampling="force" or
  52. "clearcpuid=avx" on the kernel command-line.
  53. If used, these options will disable AVX use by turning off XSAVE YMM support.
  54. However, the processor will still enumerate AVX support. Userspace that
  55. does not follow proper AVX enumeration to check both AVX *and* XSAVE YMM
  56. support will break.
  57. Mitigation control on the kernel command line
  58. ---------------------------------------------
  59. The mitigation can be disabled by setting "gather_data_sampling=off" or
  60. "mitigations=off" on the kernel command line. Not specifying either will default
  61. to the mitigation being enabled. Specifying "gather_data_sampling=force" will
  62. use the microcode mitigation when available or disable AVX on affected systems
  63. where the microcode hasn't been updated to include the mitigation.
  64. GDS System Information
  65. ------------------------
  66. The kernel provides vulnerability status information through sysfs. For
  67. GDS this can be accessed by the following sysfs file:
  68. /sys/devices/system/cpu/vulnerabilities/gather_data_sampling
  69. The possible values contained in this file are:
  70. ============================== =============================================
  71. Not affected Processor not vulnerable.
  72. Vulnerable Processor vulnerable and mitigation disabled.
  73. Vulnerable: No microcode Processor vulnerable and microcode is missing
  74. mitigation.
  75. Mitigation: AVX disabled,
  76. no microcode Processor is vulnerable and microcode is missing
  77. mitigation. AVX disabled as mitigation.
  78. Mitigation: Microcode Processor is vulnerable and mitigation is in
  79. effect.
  80. Mitigation: Microcode (locked) Processor is vulnerable and mitigation is in
  81. effect and cannot be disabled.
  82. Unknown: Dependent on
  83. hypervisor status Running on a virtual guest processor that is
  84. affected but with no way to know if host
  85. processor is mitigated or vulnerable.
  86. ============================== =============================================
  87. GDS Default mitigation
  88. ----------------------
  89. The updated microcode will enable the mitigation by default. The kernel's
  90. default action is to leave the mitigation enabled.