Повреждение памяти Zephyr через использование после освобождения (use-after-free) в драйвере SEDI I2C
Zephyr
Кратко
В драйвере Intel SEDI I2C в Zephyr состояние гонки после тайм-аута передачи оставляет устаревший токен завершения, что позволяет последующей передаче завершиться досрочно, пока контроллер ещё записывает данные в буфер вызывающей стороны. Злоумышленник с физическим доступом к шине I2C, например, через модифицированное периферийное устройство, управляющее растяжением тактового сигнала, может использовать это для повреждения памяти стека ядра или потока данными, предоставляемыми периферией, что может привести к сбою системы или потенциально к выполнению кода без входа в систему или каких-либо действий пользователя.
Резюме сгенерировано ИИ по данным источников и переведено автоматически.
Исправление
Исправлено в версиях: 4.3.24.5.0
Затронутые версии
| zephyr | с 3.5.0 → исправлено в 4.3.2 с 4.4.0 → исправлено в 4.5.0 |
Оригинальное описание (EN)
Оригинальный заголовок: Zephyr memory corruption via use-after-free in SEDI I2C driver
The Intel SEDI I2C controller driver (drivers/i2c/i2c_sedi.c, used on Intel ISH platforms) waits for each asynchronous transfer with k_sem_take() on a per-controller completion semaphore and a 1 s timeout. When the wait times out, i2c_sedi_api_full_io() aborts the transfer via SEDI_I2C_ABORT_TRANSFER, but if the controller's completion interrupt fires between the timeout expiring and the abort masking interrupts, the callback k_sem_give()s the semaphore and the token is never discarded. The next transfer on that bus then takes the stale token immediately and returns success (the stale context->err is usually 0) while the controller is still executing it. The HAL interrupt handler (or DMA) keeps copying received bytes into the caller's msgs[i].buf. Since I2C callers typically pass stack buffers, this writes into a stack frame that has already been returned from, and the caller also consumes incomplete data. The desynchronization can persist across later transfers. Triggering the race requires a transfer to complete just after the 1 s timeout. A device on the I2C bus that controls clock stretching (for example a malicious or tampered peripheral) can steer this timing, and it also supplies the bytes that get written. Exploitation therefore needs physical access to the bus and is timing-dependent. The impact is corruption of kernel or thread stack memory with data the peripheral controls, which can lead to a crash or potentially to code execution. The fix calls k_sem_reset() and clears context->err after the abort, while the transfer mutex is still held.