Ad

CVE-2026-89958

NONE EPSS 0.21%
Обновлено 30 октября 2026
Linux
Параметр Значение
Поставщик Linux
Публичный эксплойт Нет

В ядре Linux была устранена следующая уязвимость: s390/vfio-ap: Fix dereference matrix_mdev->kvm без проверки на структуру NULL The ap_driver имеет два поля, которые являются функциональными указателями на обратные вызовы: * .on_config_changed: вызывается в начале функции сканирования шины AP, чтобы уведомить драйвер устройства о том, что конфигурация хоста AP изменилась и соответствующие устройства AP будут соответственно удалены. Это дает реализатору возможность оценить изменения конфигурации и отреагировать на них до добавления или удаления соответствующих устройств. * .on_scan_complete: Called в конце функции сканирования шины AP, чтобы уведомить драйвер устройства о том, что конфигурация хоста AP изменилась, а устройства AP были добавлены или удалены соответственно. Это дает реализатору возможность реагировать на изменения после добавления или удаления соответствующих устройств.

Эти два обратного вызова реализованы в драйвере устройства vfio_ap через функции vfio_ap_on_cfg_changed и vfio_ap_on_scan_complete соответственно. В стеке вызовов этих двух функций обратного вызова мютекс matrix_mdev->kvm->lock принимается без проверки, является ли matrix_mdev->kvm NULL или нет. Если matrix_mdev->kvm никогда не был установлен, попытка взять блокировку вызовет удаление указателя NULL.

Этот патч добавляет проверки для matrix_mdev->kvm NULL перед принятием мьютекса matrix_mdev->kvm->lock. Обратите внимание, что мютекс matrix_mdev->kvm->lock, принятый в функции vfio_ap_mdev_hot_plug_config, перемещается в вызывающую функцию вместе с matrix_dev->mdevs_lock, которая необходима там для доступа к полям matrix_mdev. Нет смысла менять проверку на matrix_mdev->kvm там, прежде чем принимать мютекс kvm->lock, только для того, чтобы переместить его через другой патч, так что это делается в этом патч.

Важно отметить следующее: 1. matrix_dev->guests_lock приобретается в начале обеих функций обратного вызова. Это гарантирует, что matrix_mdev не будет удален с помощью функции vfio_ap_mdev_remove, потому что он также принимает matrix_dev_guests_lock перед удалением объекта; таким образом, matrix_mdev будет доступен на протяжении всех функций обратного вызова. 2. Мьютекс matrix_dev->mdevs_lock должен быть взят, чтобы получить доступ к полям в структуре matrix_mdev.

Мьютекс matrix_mdev->kvm->lock должен быть взят перед matrix_dev->mdevs_lock, чтобы предотвратить замыкание. 4: The kvm->lock должен удерживаться при подключении конфигурации гостя AP к описанию состояния SIE с помощью функции vfio_ap_mdev_update_guest_apcb. 5. vfio_ap_mdev_update_guest_apcb проверяет matrix_mdev->kvm, чтобы убедиться, что это не NULL, прежде чем делать горячий разъем конфигурации AP гостя.

Показать оригинальное описание (EN)

In the Linux kernel, the following vulnerability has been resolved: s390/vfio-ap: Fix dereference matrix_mdev->kvm without checking for NULL The ap_driver structure has two fields which are function pointers to callbacks: * .on_config_changed: called at the start of the AP bus scan function to notify the device driver that the host AP configuration has changed and the associated AP devices will be added or removed accordingly. This gives the implementor a chance to evaluate the configuration changes and respond to them before the associated devices are added or removed. * .on_scan_complete: Called at the end of the AP bus scan function to notify the device driver that the host AP configuration has changed and the AP devices have been added or removed accordingly. This gives the implementor the opportunity to respond to the changes after the associated devices are added or removed. These two callbacks are implemented in the vfio_ap device driver via the vfio_ap_on_cfg_changed and vfio_ap_on_scan_complete functions respectively. Within the call stack of these two callback functions the matrix_mdev->kvm->lock mutex is taken without checking whether matrix_mdev->kvm is NULL or not. If matrix_mdev->kvm has never been set, trying to take the lock will trigger a NULL pointer dereference. This patch adds checks for matrix_mdev->kvm == NULL before taking the matrix_mdev->kvm->lock mutex. Note that the matrix_mdev->kvm->lock mutex taken in the vfio_ap_mdev_hot_plug_config function is moved to the calling function along with the matrix_dev->mdevs_lock which is needed there to access the fields of the matrix_mdev. It makes little sense to make the change the check for matrix_mdev->kvm there before taking the kvm->lock mutex only to have to move it out via another patch, so it is done in this patch. It is important to make note of the following: 1. The matrix_dev->guests_lock is acquired at the start of both callback functions. This ensures that matrix_mdev will not be removed via the vfio_ap_mdev_remove function because it too takes matrix_dev_guests_lock before removing the object; so, matrix_mdev will be available for the duration of the callback functions. 2. The matrix_dev->mdevs_lock mutex must be taken in order to access fields within the matrix_mdev structure 3. matrix_mdev->kvm->lock mutex must be taken before the matrix_dev->mdevs_lock to prevent a lockdep splat. 4: The kvm->lock must be held while plugging the guest's AP configuration into its SIE state description via the vfio_ap_mdev_update_guest_apcb function. 5. The vfio_ap_mdev_update_guest_apcb checks matrix_mdev->kvm to verify it is not NULL before doing the hot plug of the guest's AP configuration.