В ядре Linux устранена следующая уязвимость:
KVM: x86: загружайте DR6 со значением гостя только перед входом в цикл .vcpu_run(). Переместите условную загрузку аппаратного DR6 со значением DR6 гостя.
из основного цикла .vcpu_run(), чтобы исправить ошибку, при которой KVM может загружать оборудование
с устаревшим vcpu->arch.dr6. Когда гость обращается к аварийному восстановлению, а пользовательское пространство хоста не выполняет отладку гостя,
KVM отключает перехват DR и загружает значения гостя в оборудование на
VM-Enter и сохраняет их при VM-Exit.
Это позволяет гостю получить доступ к DR.
по желанию, напр. чтобы последовательность обращений к DR для настройки точки останова
генерирует только один VM-Exit. Для DR0-DR3 логика/поведение VMX и SVM идентична, а также
идентично KVM_DEBUGREG_BP_ENABLED (пользовательское пространство отладки гостя)
и KVM_DEBUGREG_WONT_EXIT (гость, использующий DR), поэтому KVM обрабатывает загрузку
DR0-DR3 в общем коде, _вне_ основного цикла kvm_x86_ops.vcpu_run(). Но для DR6 значение гостя не нужно загружать в аппаратное обеспечение.
KVM_DEBUGREG_BP_ENABLED, а SVM предоставляет выделенное поле VMCB, тогда как
VMX требует, чтобы программное обеспечение вручную загружало значение гостя и, таким образом, загружало
значение гостя в DR6 обрабатывается с помощью {svm,vmx}_vcpu_run(), т.е. выполняется
_внутри_ основного цикла выполнения.
К сожалению, сохранение гостевых значений на VM-Exit инициируется общим x86, опять же за пределами основного цикла выполнения. Если гость изменяет DR6 (в аппаратно, когда перехват DR отключен), а затем следующий VM-Exit быстрый путь VM-Exit, KVM перезагрузит аппаратный DR6 с помощью vcpu->arch.dr6 и стереть реальную ценность гостя. Ошибка проявляется в первую очередь при использовании вложенного VMX, поскольку KVM обрабатывает VMX. таймер вытеснения в быстром пути и окно между аппаратным DR6 модифицируется (в гостевом контексте), а DR6 читается гостевым программным обеспечением. на порядки больше во вложенной установке.
Например. во невложенных,
Таймер вытеснения VMX должен срабатывать точно между внедрением #DB.
и чтение DR6 обработчиком #DB, тогда как при настройке KVM-on-KVM
окно, в котором аппаратный DR6 «грязный», простирается до момента записи L1
DR6 в VMRESUME (в L1). Взгляд L1:
==========
<L1 отключает перехват DR>
ЦП 0/KVM-7289 [023] d.... 2925.640961: kvm_entry: vcpu 0
A: L1 записывает DR6
CPU 0/KVM-7289 [023] d.... 2925.640963: <хак>: Установить DR, DR6 = 0xffff0ff1
B: CPU 0/KVM-7289 [023] d.... 2925.640967: kvm_exit: vcpu 0 причина EXTERNAL_INTERRUPT intr_info 0x800000ec
D: L1 читает DR6, арх.dr6 = 0
CPU 0/KVM-7289 [023] d.... 2925.640969: <хак>: синхронизировать DR, DR6 = 0xffff0ff0
ЦП 0/KVM-7289 [023] d.... 2925.640976: kvm_entry: vcpu 0
L2 читает DR6, L1 отключает перехват DR
CPU 0/KVM-7289 [023] d.... 2925.640980: kvm_exit: vcpu 0 причина DR_ACCESS info1 0x0000000000000216
ЦП 0/KVM-7289 [023] d.... 2925.640983: kvm_entry: vcpu 0
CPU 0/KVM-7289 [023] d.... 2925.640983: <хак>: Установить DR, DR6 = 0xffff0ff0
L2 обнаруживает сбой
CPU 0/KVM-7289 [023] d.... 2925.640987: kvm_exit: vcpu 0 причина HLT
L1 читает DR6 (подтверждает сбой)
CPU 0/KVM-7289 [023] d.... 2925.640990: <хак>: Синхронизировать DR, DR6 = 0xffff0ff0
Мнение L0:
==========
L2 читает DR6, арх.dr6 = 0
CPU 23/KVM-5046 [001] d.... 3410.005610: kvm_exit: vcpu 23 причина DR_ACCESS info1 0x0000000000000216
CPU 23/KVM-5046 [001]..... 3410.005610: kvm_nested_vmexit: vcpu 23 причина DR_ACCESS info1 0x0000000000000216
L2 => L1 вложенный выход из виртуальной машины
CPU 23/KVM-5046 [001]..... 3410.005610: kvm_nested_vmexit_inject: причина: DR_ACCESS ext_inf1: 0x0000000000000216
CPU 23/KVM-5046 [001] d.... 3410.005610: kvm_entry: vcpu 23
CPU 23/KVM-5046 [001] d.... 3410.005611: kvm_exit: vcpu 23 причина VMREAD
ЦП 23/KVM-5046 [001] d.... 3410.005611: kvm_entry: vcpu 23
ЦП 23/KVM-5046 [001] д.... 3410.
---усечено---
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: KVM: x86: Load DR6 with guest value only before entering .vcpu_run() loop Move the conditional loading of hardware DR6 with the guest's DR6 value out of the core .vcpu_run() loop to fix a bug where KVM can load hardware with a stale vcpu->arch.dr6. When the guest accesses a DR and host userspace isn't debugging the guest, KVM disables DR interception and loads the guest's values into hardware on VM-Enter and saves them on VM-Exit. This allows the guest to access DRs at will, e.g. so that a sequence of DR accesses to configure a breakpoint only generates one VM-Exit. For DR0-DR3, the logic/behavior is identical between VMX and SVM, and also identical between KVM_DEBUGREG_BP_ENABLED (userspace debugging the guest) and KVM_DEBUGREG_WONT_EXIT (guest using DRs), and so KVM handles loading DR0-DR3 in common code, _outside_ of the core kvm_x86_ops.vcpu_run() loop. But for DR6, the guest's value doesn't need to be loaded into hardware for KVM_DEBUGREG_BP_ENABLED, and SVM provides a dedicated VMCB field whereas VMX requires software to manually load the guest value, and so loading the guest's value into DR6 is handled by {svm,vmx}_vcpu_run(), i.e. is done _inside_ the core run loop. Unfortunately, saving the guest values on VM-Exit is initiated by common x86, again outside of the core run loop. If the guest modifies DR6 (in hardware, when DR interception is disabled), and then the next VM-Exit is a fastpath VM-Exit, KVM will reload hardware DR6 with vcpu->arch.dr6 and clobber the guest's actual value. The bug shows up primarily with nested VMX because KVM handles the VMX preemption timer in the fastpath, and the window between hardware DR6 being modified (in guest context) and DR6 being read by guest software is orders of magnitude larger in a nested setup. E.g. in non-nested, the VMX preemption timer would need to fire precisely between #DB injection and the #DB handler's read of DR6, whereas with a KVM-on-KVM setup, the window where hardware DR6 is "dirty" extends all the way from L1 writing DR6 to VMRESUME (in L1). L1's view: ========== <L1 disables DR interception> CPU 0/KVM-7289 [023] d.... 2925.640961: kvm_entry: vcpu 0 A: L1 Writes DR6 CPU 0/KVM-7289 [023] d.... 2925.640963: <hack>: Set DRs, DR6 = 0xffff0ff1 B: CPU 0/KVM-7289 [023] d.... 2925.640967: kvm_exit: vcpu 0 reason EXTERNAL_INTERRUPT intr_info 0x800000ec D: L1 reads DR6, arch.dr6 = 0 CPU 0/KVM-7289 [023] d.... 2925.640969: <hack>: Sync DRs, DR6 = 0xffff0ff0 CPU 0/KVM-7289 [023] d.... 2925.640976: kvm_entry: vcpu 0 L2 reads DR6, L1 disables DR interception CPU 0/KVM-7289 [023] d.... 2925.640980: kvm_exit: vcpu 0 reason DR_ACCESS info1 0x0000000000000216 CPU 0/KVM-7289 [023] d.... 2925.640983: kvm_entry: vcpu 0 CPU 0/KVM-7289 [023] d.... 2925.640983: <hack>: Set DRs, DR6 = 0xffff0ff0 L2 detects failure CPU 0/KVM-7289 [023] d.... 2925.640987: kvm_exit: vcpu 0 reason HLT L1 reads DR6 (confirms failure) CPU 0/KVM-7289 [023] d.... 2925.640990: <hack>: Sync DRs, DR6 = 0xffff0ff0 L0's view: ========== L2 reads DR6, arch.dr6 = 0 CPU 23/KVM-5046 [001] d.... 3410.005610: kvm_exit: vcpu 23 reason DR_ACCESS info1 0x0000000000000216 CPU 23/KVM-5046 [001] ..... 3410.005610: kvm_nested_vmexit: vcpu 23 reason DR_ACCESS info1 0x0000000000000216 L2 => L1 nested VM-Exit CPU 23/KVM-5046 [001] ..... 3410.005610: kvm_nested_vmexit_inject: reason: DR_ACCESS ext_inf1: 0x0000000000000216 CPU 23/KVM-5046 [001] d.... 3410.005610: kvm_entry: vcpu 23 CPU 23/KVM-5046 [001] d.... 3410.005611: kvm_exit: vcpu 23 reason VMREAD CPU 23/KVM-5046 [001] d.... 3410.005611: kvm_entry: vcpu 23 CPU 23/KVM-5046 [001] d.... 3410. ---truncated---
Характеристики атаки
Последствия
Строка CVSS v3.1
Уязвимые продукты 10
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.7.1
|
5.15.182
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.16
|
6.1.138
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.2
|
6.6.90
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.7
|
6.12.16
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.13
|
6.13.4
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:5.7:-:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:5.7:rc6:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:5.7:rc7:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.14:rc1:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.14:rc2:*:*:*:*:*:*
|
— | — |