В ядре Linux устранена следующая уязвимость:
KVM: x86: исправлена жесткая блокировка виртуальной машины после длительного бездействия с помощью периодического таймера HV. При увеличении целевого срока действия гостевого таймера APIC в периодическом
режим, установите срок действия «сейчас», если целевой срок действия находится в прошлом
(аналогично тому, что делается в update_target_expiration()). Слепое добавление
период до истечения предыдущего целевого срока может привести к генерации KVM
практически неограниченное количество IRQ hrtimer из-за программирования
истекший таймер снова и снова.
В экстремальных сценариях, напр. если пользовательское пространство приостанавливает/приостанавливает работу виртуальной машины на длительный период, это может даже привести к серьезным проблемам. зависания на хосте. В настоящее время ошибка затрагивает только процессоры Intel при использовании таймера гипервизора. (таймер HV), также известный как таймер вытеснения VMX. В отличие от программного таймера, он же hrtimer, который KVM продолжает работать даже при выходе в пользовательское пространство.
Таймер HV работает только тогда, когда гость активен. В результате, если виртуальный ЦП не будет работать в течение длительного времени, будет огромный разрыв между целевой срок действия и текущее время возобновления работы виртуального ЦП. Поскольку целевой срок действия увеличивается только на один период для каждого истечение таймера, это приводит к серии истечений таймера быстро после возобновления работы виртуального ЦП/ВМ.
Что еще более важно, когда виртуальный ЦП впервые запускает периодический таймер HV. истечение срока после возобновления, сдвиг истечения срока действия вперед только на один период приведет к истечению целевого срока в прошлом. В результате дельта может быть рассчитан как отрицательное значение. Когда дельта преобразуется в абсолютное значение (tscdeadline — это беззнаковый u64), результирующее значение может переполнить то, что способен запрограммировать таймер HV.
Т.е. большой
значение превысит максимальную разрядность таймера вытеснения VMX, равную
cpu_preemption_timer_multi + 32 и, таким образом, заставит KVM переключиться с
Таймер ВН к программному таймеру (hrtimers). После переключения на программный таймер периодические обратные вызовы по истечении таймера
может выполняться последовательно в рамках одного обработчика прерываний тактового сигнала,
потому что hrtimers выполняет запрос KVM об истечении срока действия в прошлом и
немедленно повторно вызывает обратный вызов KVM после перепрограммирования. И потому что
обработчик прерываний запускается с отключенными IRQ, перезапуская таймер KVM
снова и снова, пока целевой срок истечения не будет передвинут на «сейчас», это может привести к
в жесткой тюрьме.
Например. следующая жесткая блокировка была вызвана на хосте при запуске
Виртуальная машина Windows (актуально только потому, что она использовала таймер APIC в периодическом режиме)
после возобновления работы ВМ из длительного приостановки (на хосте). Сторожевой таймер NMI: Сторожевой таймер обнаружил жесткую блокировку на процессоре 45
... RIP: 0010:advance_ periodic_target_expiration+0x4d/0x80 [квм]
...
RSP: 0018:ff4f88f5d98d8ef0 EFLAGS: 00000046
RAX: fff0103f91be678e RBX: fff0103f91be678e RCX: 00843a7d9e127bcc
RDX: 0000000000000002 RSI: 0052ca4003697505 RDI: ff440d5bfbdbd500
RBP: ff440d5956f99200 R08: ff2ff2a42deb6a84 R09: 000000000002a6c0
R10: 0122d794016332b3 R11: 0000000000000000 R12: ff440db1af39cfc0
R13: ff440db1af39cfc0 R14: ffffffffc0d4a560 R15: ff440db1af39d0f8
FS: 00007f04a6ffd700(0000) GS:ff440db1af380000(0000) knlGS:000000e38a3b8000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000d5651feff8 CR3: 000000684e038002 CR4: 0000000000773ee0
ПКРУ: 55555554
Отслеживание вызова:
<IRQ>
apic_timer_fn+0x31/0x50 [квм]
__hrtimer_run_queues+0x100/0x280
hrtimer_interrupt+0x100/0x210
? ttwu_do_wakeup+0x19/0x160
smp_apic_timer_interrupt+0x6a/0x130
apic_timer_interrupt+0xf/0x20
</IRQ>
Более того, если продолжительность приостановки виртуальной машины недостаточно велика
чтобы вызвать жесткую блокировку в этом сценарии, начиная с фиксации 98c25ead5eda
(«KVM: VMX: переместить таймер вытеснения <=> hrtimer dance на общий x86»), KVM
продолжит использовать программный таймер до тех пор, пока гость не перепрограммирует APIC
таймер каким-то образом. Поскольку периодический таймер не требует частого APIC
программирование регистра таймера, гость может продолжать использовать программное обеспечение
таймер в
---усечено---
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: KVM: x86: Fix VM hard lockup after prolonged inactivity with periodic HV timer When advancing the target expiration for the guest's APIC timer in periodic mode, set the expiration to "now" if the target expiration is in the past (similar to what is done in update_target_expiration()). Blindly adding the period to the previous target expiration can result in KVM generating a practically unbounded number of hrtimer IRQs due to programming an expired timer over and over. In extreme scenarios, e.g. if userspace pauses/suspends a VM for an extended duration, this can even cause hard lockups in the host. Currently, the bug only affects Intel CPUs when using the hypervisor timer (HV timer), a.k.a. the VMX preemption timer. Unlike the software timer, a.k.a. hrtimer, which KVM keeps running even on exits to userspace, the HV timer only runs while the guest is active. As a result, if the vCPU does not run for an extended duration, there will be a huge gap between the target expiration and the current time the vCPU resumes running. Because the target expiration is incremented by only one period on each timer expiration, this leads to a series of timer expirations occurring rapidly after the vCPU/VM resumes. More critically, when the vCPU first triggers a periodic HV timer expiration after resuming, advancing the expiration by only one period will result in a target expiration in the past. As a result, the delta may be calculated as a negative value. When the delta is converted into an absolute value (tscdeadline is an unsigned u64), the resulting value can overflow what the HV timer is capable of programming. I.e. the large value will exceed the VMX Preemption Timer's maximum bit width of cpu_preemption_timer_multi + 32, and thus cause KVM to switch from the HV timer to the software timer (hrtimers). After switching to the software timer, periodic timer expiration callbacks may be executed consecutively within a single clock interrupt handler, because hrtimers honors KVM's request for an expiration in the past and immediately re-invokes KVM's callback after reprogramming. And because the interrupt handler runs with IRQs disabled, restarting KVM's hrtimer over and over until the target expiration is advanced to "now" can result in a hard lockup. E.g. the following hard lockup was triggered in the host when running a Windows VM (only relevant because it used the APIC timer in periodic mode) after resuming the VM from a long suspend (in the host). NMI watchdog: Watchdog detected hard LOCKUP on cpu 45 ... RIP: 0010:advance_periodic_target_expiration+0x4d/0x80 [kvm] ... RSP: 0018:ff4f88f5d98d8ef0 EFLAGS: 00000046 RAX: fff0103f91be678e RBX: fff0103f91be678e RCX: 00843a7d9e127bcc RDX: 0000000000000002 RSI: 0052ca4003697505 RDI: ff440d5bfbdbd500 RBP: ff440d5956f99200 R08: ff2ff2a42deb6a84 R09: 000000000002a6c0 R10: 0122d794016332b3 R11: 0000000000000000 R12: ff440db1af39cfc0 R13: ff440db1af39cfc0 R14: ffffffffc0d4a560 R15: ff440db1af39d0f8 FS: 00007f04a6ffd700(0000) GS:ff440db1af380000(0000) knlGS:000000e38a3b8000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000d5651feff8 CR3: 000000684e038002 CR4: 0000000000773ee0 PKRU: 55555554 Call Trace: <IRQ> apic_timer_fn+0x31/0x50 [kvm] __hrtimer_run_queues+0x100/0x280 hrtimer_interrupt+0x100/0x210 ? ttwu_do_wakeup+0x19/0x160 smp_apic_timer_interrupt+0x6a/0x130 apic_timer_interrupt+0xf/0x20 </IRQ> Moreover, if the suspend duration of the virtual machine is not long enough to trigger a hard lockup in this scenario, since commit 98c25ead5eda ("KVM: VMX: Move preemption timer <=> hrtimer dance to common x86"), KVM will continue using the software timer until the guest reprograms the APIC timer in some way. Since the periodic timer does not require frequent APIC timer register programming, the guest may continue to use the software timer in ---truncated---
Характеристики атаки
Последствия
Строка CVSS v3.1
Тип уязвимости (CWE)
Уязвимые продукты 17
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.14.45
|
4.15
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.16.13
|
4.17
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.17.1
|
5.10.248
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.11
|
5.15.198
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.16
|
6.1.160
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.2
|
6.6.120
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.7
|
6.12.64
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.13
|
6.18.3
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:4.17:-:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.19:rc1:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.19:rc2:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.19:rc3:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.19:rc4:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.19:rc5:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.19:rc6:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.19:rc7:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:6.19:rc8:*:*:*:*:*:*
|
— | — |