В ядре Linux устранена следующая уязвимость:
HID: appleir: исправлено UAF при ожидании key_up_timer в remove()
appleir_remove() запускает hid_hw_stop() раньше timer_delete_sync().
hid_hw_stop() синхронно отменяет регистрацию устройства ввода HID через
hid_disconnect() -> hidinput_disconnect() -> input_unregister_device(),
который удаляет последнюю ссылку и освобождает базовый input_dev, когда
никакой дескриптор пользовательского пространства не удерживает его открытым.
key_up_tick() читает appleir->input_dev и вызывает input_report_key() /
input_sync() на нем. Таймер включается из appleir_raw_event() с помощью
тайм-аут HZ/8 (~ 125 мс) для каждого отчета о нажатии и повторении клавиш. Если
клавиша была нажата незадолго до отключения устройства, таймер
может срабатывать после того, как hid_hw_stop() освободил input_dev, но до того, как
снос истощает его.
Простого переупорядочения недостаточно. Сначала ставим слив по таймеру
по-прежнему оставляет окно, в котором выполняется завершение USB URB (raw_event)
во время hid_hw_stop() можно вызвать mod_timer() и повторно активировать таймер, что
затем срабатывает после того, как hidinput_disconnect() освободит input_dev. То же самое
Окно URB-дополнения также позволяет raw_event() достигать key_up(), key_down().
и напрямую Battery_flat(), все из которых разыменовывают
appleir-> input_dev.
Добавьте флаг «удаления» в структуру appleir, закрытую существующей
спинлок. appleir_remove() устанавливает флаг под блокировкой, а затем
отключает таймер с помощью timer_shutdown_sync(), который истощает все
обратный вызов в реальном времени и навсегда отключает дальнейшие вызовы mod_timer().
appleir_raw_event() и key_up_tick() выходят из строя раньше, если флаг установлен.
установлен, поэтому ни один путь не может активировать или запустить таймер или разыменовать
appleir->input_dev, после того, как метод Remove() начал сноситься. Ветви keyrepeat и Flatbattery функции appleir_raw_event().
ранее вызываемый на входной уровень без удержания спин-блокировки;
сделайте это сейчас, чтобы проверка флага была четко определена. Это кстати
закрывает уже существующую гонку на стороне чтения на appleir->current_key в
ветка повторения клавиш.
Эта ошибка структурно является родственной коммиту 4db2af929279 («HID:
appletb-kbd: исправлен UAF в пути очистки таймера неактивности") и был
присутствует с момента введения драйвера.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: HID: appleir: fix UAF on pending key_up_timer in remove() appleir_remove() runs hid_hw_stop() before timer_delete_sync(). hid_hw_stop() synchronously unregisters the HID input device via hid_disconnect() -> hidinput_disconnect() -> input_unregister_device(), which drops the last reference and frees the underlying input_dev when no userspace handle holds it open. key_up_tick() reads appleir->input_dev and calls input_report_key() / input_sync() on it. The timer is armed from appleir_raw_event() with a HZ/8 (~125 ms) timeout on every keydown and key-repeat report. If a key was pressed shortly before the device is disconnected, the timer can fire after hid_hw_stop() has freed input_dev but before the teardown drains it. A simple reorder is not sufficient. Putting the timer drain first still leaves a window where a USB URB completion (raw_event) running during hid_hw_stop() can call mod_timer() and re-arm the timer, which then fires after hidinput_disconnect() has freed input_dev. The same URB-completion window also lets raw_event() reach key_up(), key_down() and battery_flat() directly, all of which dereference appleir->input_dev. Introduce a 'removing' flag on struct appleir, gated by the existing spinlock. appleir_remove() sets the flag under the lock and then shuts down the timer with timer_shutdown_sync(), which both drains any in-flight callback and permanently disables further mod_timer() calls. appleir_raw_event() and key_up_tick() bail out early if the flag is set, so no path can arm or run the timer, or dereference appleir->input_dev, after remove() has started tearing down. The keyrepeat and flatbattery branches of appleir_raw_event() previously called into the input layer without holding the spinlock; take it now so the flag check is well-defined. This incidentally closes a pre-existing read-side race on appleir->current_key in the keyrepeat branch. This bug is structurally a sibling of commit 4db2af929279 ("HID: appletb-kbd: fix UAF in inactivity-timer cleanup path") and has been present since the driver was introduced.
Характеристики атаки
Последствия
Строка CVSS v3.1
Тип уязвимости (CWE)
Уязвимые продукты 9
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
3.10
|
5.10.261
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.11
|
5.15.212
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.16
|
6.1.178
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.2
|
6.6.145
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.7
|
6.12.97
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.13
|
6.18.39
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.19
|
7.1.4
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:7.2:rc1:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:7.2:rc2:*:*:*:*:*:*
|
— | — |