В ядре Linux устранена следующая уязвимость:
mshv: заказ публикации pt_vp_array по пути утверждения irqfd
mshv_partition_ioctl_create_vp() инициализирует структуру VP (выделения,
mutex_init, init_waitqueue_head, сопоставления страниц), а затем публикует
указатель на раздел->pt_vp_array. Несколько путей ISR читают этот массив.
без блокировки: ISR перехвата, два ISR планировщика и
mshv_try_assert_irq_fast() по быстрому пути irqfd. Из них только mshv_try_assert_irq_fast() может структурно соревноваться с
опубликовать.
Он запускается из пробудителя eventfd без удержания pt_mutex и
MSHV_IRQFD не требует целевого lapic_apic_id (== vp_index) для
обратитесь к существующему вице-президенту во время регистрации. Таким образом, пользователь может
зарегистрировать irqfd, нацеленный на еще не созданного вице-президента, а затем запустить
mshv_try_assert_irq_fast() одновременно с MSHV_CREATE_VP для
тот же индекс. В слабоупорядоченных архитектурах читатель может наблюдать
ненулевой указатель в pt_vp_array перед тем, как инициализация сохранится в
Структура VP становится видимой, что приводит к использованию частично инициализированных
поля (например, vp_register_page).
Остальные читатели ISR не смогут дотянуться до этой гонки: гипервизор не будет
генерировать сообщения перехвата или планировщика для VP, который никогда не был
ему приказано запустить, и пользователь может вызывать MSHV_RUN_VP только на FD VP.
возвращается MSHV_CREATE_VP, который по конструкции возвращается после
публикация. Оставьте эти ридеры как обычные нагрузки. Используйте smp_store_release() в mshv_partition_ioctl_create_vp() для публикации.
указатель и соедините его с smp_load_acquire() в
mshv_try_assert_irq_fast().
На x86 они компилируются для простого доступа.
под ТСО; на ARM64 они создают барьеры получения/освобождения в одну инструкцию,
приемлемо на этом быстром пути. Путь на стороне уничтожения (destroy_partition() очищает pt_vp_array[i] до
NULL после kfree(vp)) имеет отдельную проблему порядка и срока службы.
здесь это выходит за рамки.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: mshv: Order pt_vp_array publish against irqfd assertion path mshv_partition_ioctl_create_vp() initialises a VP struct (allocations, mutex_init, init_waitqueue_head, page mappings) and then publishes the pointer into partition->pt_vp_array. Several ISR paths read this array locklessly: the intercept ISR, the two scheduler ISRs, and mshv_try_assert_irq_fast() on the irqfd fast path. Of these, only mshv_try_assert_irq_fast() can structurally race the publish. It runs from an eventfd waker without holding pt_mutex, and MSHV_IRQFD does not require the target lapic_apic_id (== vp_index) to refer to an existing VP at registration time. A user can therefore register an irqfd targeting a yet-to-be-created VP, then trigger mshv_try_assert_irq_fast() concurrently with MSHV_CREATE_VP for the same index. On weakly-ordered architectures the reader can observe a non-NULL pointer in pt_vp_array before the initialising stores to the VP struct become visible, leading to use of partially-initialised fields (e.g. vp_register_page). The other ISR readers cannot reach this race: the hypervisor will not generate intercept or scheduler messages for a VP that has never been told to run, and the user can only call MSHV_RUN_VP on the VP fd returned by MSHV_CREATE_VP, which by construction is returned after the publish. Leave those readers as plain loads. Use smp_store_release() in mshv_partition_ioctl_create_vp() to publish the pointer, and pair it with smp_load_acquire() in mshv_try_assert_irq_fast(). On x86 these compile to plain accesses under TSO; on ARM64 they emit one-instruction acquire/release barriers, acceptable on this fast path. The destroy-side path (destroy_partition() clearing pt_vp_array[i] to NULL after kfree(vp)) has a separate ordering and lifetime concern that is out of scope here.