В ядре Linux устранена следующая уязвимость: serial: core: shutdown initialized port on removal When Последовательный порт, настроенный как консоль, открывается и впоследствии закрывается, tty_port_shutdown() пропускает вызов port->ops->shutdown(), так как port->console является истинным. В результате tty_port_initialized() остается верным, а обработчик прерываний порта остается зарегистрированным в подсистеме irq. Если базовое устройство позже отсоединено или удалено (например, через драйвер sysfs unbind или устройство hot-unplug), serial_core_remove_one_port () отключает консоль, освобождает uport->name через kfree () и разрывает порт, не выключая его или освобождая его IRQ.
Следовательно, дескриптор irqaction остается зарегистрированным в genirq с action->name, указывающим на освобожденную память. Это вызывает чтение use-after-free всякий раз, когда genirq обращается к action->name, например, при чтении /proc / прерываниях: BUG: KASAN: slab-use-after-free в string+0x476/0x570 Call Trace: string+0x476/0x570 vsnprintf+0x422/0x1300 seq_printf+0x... show_interrupts+... Исправьте это, приобретя port->mutex в serial_core_remove_one_port () после отмены регистрации консоли, очистив port->console под мьютексом, чтобы предотвратить гонку данных с одновременным tty_port_shutdown (), и вызвав uart_shutdown(NULL, состояние), если порт остается инициализированным.
Это гарантирует, что port->ops->shutdown() вызывается, и IRQ освобождается до kfree(uport->name).
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: serial: core: shut down initialized port on removal When a serial port configured as a console is opened and subsequently closed, tty_port_shutdown() skips invoking port->ops->shutdown() because port->console is true. As a result, tty_port_initialized() remains true and the port's interrupt handler stays registered in the irq subsystem. If the underlying device is later unbound or removed (e.g. via sysfs driver unbind or device hot-unplug), serial_core_remove_one_port() unregisters the console, frees uport->name via kfree(), and tears down the port without shutting it down or freeing its IRQ. Consequently, the irqaction descriptor remains registered in genirq with action->name pointing to freed memory. This triggers a use-after-free read whenever genirq accesses action->name, such as when reading /proc/interrupts: BUG: KASAN: slab-use-after-free in string+0x476/0x570 Call Trace: string+0x476/0x570 vsnprintf+0x422/0x1300 seq_printf+0x... show_interrupts+... Fix this by acquiring port->mutex in serial_core_remove_one_port() after console unregistration, clearing port->console under the mutex to prevent data races with concurrent tty_port_shutdown(), and invoking uart_shutdown(NULL, state) if the port remains initialized. This ensures that port->ops->shutdown() is called and the IRQ is freed before kfree(uport->name).