Ad

CVE-2021-47634

HIGH CVSS 3.1: 7,8 EPSS 0.29%
Обновлено 24 марта 2025
Linux
Параметр Значение
CVSS 7,8 (HIGH)
Уязвимые версии 3.10.103 — 5.4.189
Устранено в версии 3.3
Тип уязвимости CWE-416 (Использование памяти после освобождения)
Поставщик Linux
Публичный эксплойт Нет

В ядре Linux устранена следующая уязвимость: ubi: исправлено состояние гонки между ctrl_cdev_ioctl и ubi_cdev_ioctl. Hulk Robot сообщил отчет KASAN об использовании после освобождения: ============================================================== ОШИБКА: KASAN: использование после освобождения в __list_del_entry_valid+0x13d/0x160 Чтение размера 8 по адресу ffff888035e37d98 с помощью задачи ubiattach/1385. [...] Отслеживание вызова: klist_dec_and_del+0xa7/0x4a0 klist_put+0xc7/0x1a0 устройство_del+0x4d4/0xed0 cdev_device_del+0x1a/0x80 ubi_attach_mtd_dev+0x2951/0x34b0 [ubi] ctrl_cdev_ioctl+0x286/0x2f0 [ubi] Выделено заданием 1414: device_add+0x60a/0x18b0 cdev_device_add+0x103/0x170 ubi_create_volume+0x1118/0x1a10 [ubi] ubi_cdev_ioctl+0xb7f/0x1ba0 [ubi] Освобожден заданием 1385: cdev_device_del+0x1a/0x80 ubi_remove_volume+0x438/0x6c0 [ubi] ubi_cdev_ioctl+0xbf4/0x1ba0 [ubi] [...] ============================================================== Блокировка, удерживаемая ctrl_cdev_ioctl, — это ubi_devices_mutex, но блокировка удерживается от ubi_cdev_ioctl — это ubi->device_mutex. Таким образом, два замка могут быть одновременно. ctrl_cdev_ioctl содержит две операции: ubi_attach и ubi_detach. ubi_detach не содержит ошибок, поскольку использует подсчет ссылок для предотвращения параллелизм.

Однако uif_init и uif_close в ubi_attach могут соревноваться с ubi_cdev_ioctl. uif_init будет соревноваться с ubi_cdev_ioctl, как показано в следующем стеке. процессор1 процессор2 процессор3 _______________________|________________________|______________________ ctrl_cdev_ioctl ubi_attach_mtd_dev uif_init ubi_cdev_ioctl ubi_create_volume cdev_device_add ubi_add_volume // sysfs существуют kill_volumes ubi_cdev_ioctl ubi_remove_volume cdev_device_del // первый бесплатный ubi_free_volume cdev_del // двойное освобождение cdev_device_del И uif_close будет соревноваться с ubi_cdev_ioctl, как показано в следующем стеке. процессор1 процессор2 процессор3 _______________________|________________________|______________________ ctrl_cdev_ioctl ubi_attach_mtd_dev uif_init ubi_cdev_ioctl ubi_create_volume cdev_device_add ubi_debugfs_init_dev //ошибка перехода out_uif; uif_close kill_volumes ubi_cdev_ioctl ubi_remove_volume cdev_device_del // первый бесплатный ubi_free_volume // двойное освобождение Причина этой проблемы в том, что фиксация 714fb87e8bc0 делает устройство «доступен» до того, как он станет доступен через sysfs. Поэтому мы откатить модификацию. Мы исправим состояние гонки между создание устройства ubi и udev, удалив ubi_get_device в vol_attribute_show и dev_attribute_show.

Это позволяет избежать доступа неинициализированные ubi_devices[ubi_num]. ubi_get_device используется для предотвращения удаления устройств во время выполнение sysfs. Однако теперь kernfs гарантирует, что устройства не будут быть удалены до того, как будет запущен весь подсчет ссылок. Ключевой процесс показан в следующем стеке. устройство_del device_remove_attrs device_remove_groups sysfs_remove_groups sysfs_remove_group удалить_файлы kernfs_remove_by_name kernfs_remove_by_name_ns __kernfs_remove kernfs_drain

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

In the Linux kernel, the following vulnerability has been resolved: ubi: Fix race condition between ctrl_cdev_ioctl and ubi_cdev_ioctl Hulk Robot reported a KASAN report about use-after-free: ================================================================== BUG: KASAN: use-after-free in __list_del_entry_valid+0x13d/0x160 Read of size 8 at addr ffff888035e37d98 by task ubiattach/1385 [...] Call Trace: klist_dec_and_del+0xa7/0x4a0 klist_put+0xc7/0x1a0 device_del+0x4d4/0xed0 cdev_device_del+0x1a/0x80 ubi_attach_mtd_dev+0x2951/0x34b0 [ubi] ctrl_cdev_ioctl+0x286/0x2f0 [ubi] Allocated by task 1414: device_add+0x60a/0x18b0 cdev_device_add+0x103/0x170 ubi_create_volume+0x1118/0x1a10 [ubi] ubi_cdev_ioctl+0xb7f/0x1ba0 [ubi] Freed by task 1385: cdev_device_del+0x1a/0x80 ubi_remove_volume+0x438/0x6c0 [ubi] ubi_cdev_ioctl+0xbf4/0x1ba0 [ubi] [...] ================================================================== The lock held by ctrl_cdev_ioctl is ubi_devices_mutex, but the lock held by ubi_cdev_ioctl is ubi->device_mutex. Therefore, the two locks can be concurrent. ctrl_cdev_ioctl contains two operations: ubi_attach and ubi_detach. ubi_detach is bug-free because it uses reference counting to prevent concurrency. However, uif_init and uif_close in ubi_attach may race with ubi_cdev_ioctl. uif_init will race with ubi_cdev_ioctl as in the following stack. cpu1 cpu2 cpu3 _______________________|________________________|______________________ ctrl_cdev_ioctl ubi_attach_mtd_dev uif_init ubi_cdev_ioctl ubi_create_volume cdev_device_add ubi_add_volume // sysfs exist kill_volumes ubi_cdev_ioctl ubi_remove_volume cdev_device_del // first free ubi_free_volume cdev_del // double free cdev_device_del And uif_close will race with ubi_cdev_ioctl as in the following stack. cpu1 cpu2 cpu3 _______________________|________________________|______________________ ctrl_cdev_ioctl ubi_attach_mtd_dev uif_init ubi_cdev_ioctl ubi_create_volume cdev_device_add ubi_debugfs_init_dev //error goto out_uif; uif_close kill_volumes ubi_cdev_ioctl ubi_remove_volume cdev_device_del // first free ubi_free_volume // double free The cause of this problem is that commit 714fb87e8bc0 make device "available" before it becomes accessible via sysfs. Therefore, we roll back the modification. We will fix the race condition between ubi device creation and udev by removing ubi_get_device in vol_attribute_show and dev_attribute_show.This avoids accessing uninitialized ubi_devices[ubi_num]. ubi_get_device is used to prevent devices from being deleted during sysfs execution. However, now kernfs ensures that devices will not be deleted before all reference counting are released. The key process is shown in the following stack. device_del device_remove_attrs device_remove_groups sysfs_remove_groups sysfs_remove_group remove_files kernfs_remove_by_name kernfs_remove_by_name_ns __kernfs_remove kernfs_drain

Характеристики атаки

Способ атаки
Локальный
Нужен локальный доступ
Сложность
Низкая
Легко эксплуатировать
Нужны права
Низкие
Нужны базовые права
Участие пользователя
Не требуется
Не нужно действие пользователя

Последствия

Конфиденциальность
Высокое
Полная утечка данных
Целостность
Высокое
Полная модификация данных
Доступность
Высокое
Полный отказ в обслуживании

Строка CVSS v3.1

Уязвимые продукты 15

Конфигурация От (включительно) До (исключительно)
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
3.2.84 3.3
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
3.10.103 3.11
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
3.12.63 3.13
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
3.14.77 3.15
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
3.16.39 3.17
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
3.18.40 3.19
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
4.1.31 4.2
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
4.4.19 4.5
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
4.7.2 4.14.276
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
4.15 4.19.238
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
4.20 5.4.189
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
5.5 5.10.110
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
5.11 5.15.33
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
5.16 5.16.19
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
5.17 5.17.2