В ядре Linux устранена следующая уязвимость:
wifi: ath9k: hif_usb: не разыменовывать hif_dev после запроса на повторную постановку прошивки
ath9k_hif_request_firmware() повторно запускает асинхронную загрузку прошивки через
request_firmware_nowait(), передавая hif_dev в качестве контекста завершения и
затем все равно разыменовывает hif_dev:
dev_info(&hif_dev->udev->dev, "ath9k_htc: Запрошена прошивка %s\n",
hif_dev->fw_name);
Повторный обратный вызов ath9k_hif_usb_firmware_cb() выполняется по «событиям».
workqueue и, когда прошивка отсутствует, переводит цепочку повторов в
ath9k_hif_usb_firmware_fail() -> Complete_all(&hif_dev->fw_done). Это
одновременно выпускает wait_for_completion(&hif_dev->fw_done)
ath9k_hif_usb_disconnect(), который затем kfree() вызывает hif_dev. Замыкающий
Таким образом, dev_info() в кадре, который повторно активировал запрос, может считаться освобожденным.
память (hif_dev->udev, первое поле структуры hif_device_usb):
ОШИБКА: KASAN: использование плиты после освобождения в ath9k_hif_request_firmware
Чтение размера 8... по задаче kworker/...
ath9k_hif_request_firmware
ath9k_hif_usb_firmware_cb driver/net/wireless/ath/ath9k/hif_usb.c:1247
request_firmware_work_func
Выделено...:
драйверы ath9k_hif_usb_probe/net/wireless/ath/ath9k/hif_usb.c
Освобожден...:
ath9k_hif_usb_disconnect -> kfree driver/net/wireless/ath/ath9k/hif_usb.c
Барьер fw_done только заставляет отключить ожидание завершения цепочки прошивки.
*прекратить*; он не защищает внешний ath9k_hif_request_firmware()
кадр, который повторно активировал запрос и после этого продолжает касаться hif_dev.
Отбросьте пост-запрос dev_info(): это единственное использование hif_dev после
асинхронный запрос активирован и носит чисто информационный характер (dev_err() в
путь отказа выполняется только тогда, когда request_firmware_nowait() не активировал обратный вызов,
так что hif_dev там еще жив). Впервые об этом сообщил syzbot как об одиночном невоспроизведенном сбое, который был
позже автоматически устарел и был независимо заново открыт фаззером reFuzz,
который создал воспроизводитель C (подключение/отключение USB-гаджета ath9k_htc
устройство, загрузка прошивки которого не удалась). Уязвимый код не изменился и
все еще присутствует в v7.1-rc6, где slab-use-after-free воспроизводится под KASAN
как только окно гонки (субмикросекунды) расширится.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: wifi: ath9k: hif_usb: don't dereference hif_dev after re-arming firmware request ath9k_hif_request_firmware() re-arms an asynchronous firmware load via request_firmware_nowait(), passing hif_dev as the completion context, and then still dereferences hif_dev: dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n", hif_dev->fw_name); The re-armed callback ath9k_hif_usb_firmware_cb() runs on the "events" workqueue and, when the firmware is missing, walks the retry chain into ath9k_hif_usb_firmware_fail() -> complete_all(&hif_dev->fw_done). That releases the wait_for_completion(&hif_dev->fw_done) in a concurrent ath9k_hif_usb_disconnect(), which then kfree()s hif_dev. The trailing dev_info() in the frame that re-armed the request can therefore read freed memory (hif_dev->udev, the first field of struct hif_device_usb): BUG: KASAN: slab-use-after-free in ath9k_hif_request_firmware Read of size 8 ... by task kworker/... ath9k_hif_request_firmware ath9k_hif_usb_firmware_cb drivers/net/wireless/ath/ath9k/hif_usb.c:1247 request_firmware_work_func Allocated by ...: ath9k_hif_usb_probe drivers/net/wireless/ath/ath9k/hif_usb.c Freed by ...: ath9k_hif_usb_disconnect -> kfree drivers/net/wireless/ath/ath9k/hif_usb.c The fw_done barrier only makes disconnect wait for the firmware chain to *terminate*; it does not protect the outer ath9k_hif_request_firmware() frame that re-armed the request and keeps touching hif_dev afterwards. Drop the post-request dev_info(): it is the only use of hif_dev after the async request is armed, and it is purely informational (the dev_err() on the failure path runs only when request_firmware_nowait() did not arm a callback, so hif_dev is still alive there). This was first reported by syzbot as a single, non-reproduced crash that was later auto-obsoleted, and was independently rediscovered by the reFuzz fuzzer, which produced a C reproducer (USB-gadget connect/disconnect of an ath9k_htc device whose firmware download fails). The vulnerable code is unchanged and still present in v7.1-rc6, where the slab-use-after-free reproduces under KASAN once the (sub-microsecond) race window is widened.