В ядре Linux устранена следующая уязвимость:
ALSA: us144mkii: повторно привязывать URB захвата при повторной отправке
capture_urb_complete() повторно отправляет каждый URB захвата, не привязывая его:
usb_get_urb (город);
ret = usb_submit_urb (urb, GFP_ATOMIC);
Привязка является свойством подачи, а не URB. Возврат
path вызывает usb_unanchor_urb() перед urb->complete(), поэтому URB
повторно отправлено из собственного обработчика завершения, снято с привязки. URB захвата привязываются один раз, в начале потока, то есть с первого
завершение вперед tascam->capture_anchor пусто.
tascam_free_urbs(), tascam_disconnect(), tascam_suspend() и
путь остановки работы, все вызовы usb_kill_anchored_urbs(&tascam->capture_anchor)
чтобы получить URB захвата до того, как что-либо будет освобождено.
С якорем пустым
эти вызовы возвращаются немедленно, а URB остаются в очереди на хосте.
контроллер.
tascam_free_urbs() затем возвращает буферы передачи захвата с помощью
usb_free_coherent() и snd_card_free() освобождают snd_card.
выделение, включающее tascam (card->private_data). Контроллер
после этого завершает поставленные в очередь URB, записывая данные, предоставленные устройством, в
освобожденный буфер передачи, а capture_urb_complete() разыменовывает
освобожденный объект драйвера. КАСАН на 7.2.0-rc5 (arm64):
ОШИБКА: KASAN: использование плиты после освобождения в dummy_timer
Запись размера 512 по адресу ffff000015b62000.
__asan_memcpy
dummy_timer
hrtimer_run_softirq
Выделено заданием 64:
usb_alloc_coherent
tascam_alloc_urbs
tascam_probe
Освобожден заданием 170:
usb_free_coherent
tascam_free_urbs
tascam_disconnect
usb_unbind_interface
ОШИБКА: KASAN: использование плит после освобождения в capture_urb_complete.
Считайте размер 4 по адресу ffff0000170ee878. Освобожден заданием 170:
Release_card_device
snd_card_free
tascam_disconnect
Восстановите usb_anchor_urb() между отметкой счетчика ссылок и
повторная подача. Это также приводит к сбою обработчика usb_unanchor_urb().
рука снова имеет смысл и восстанавливает usb_kill_anchored_urbs() как барьер
на путях отключения, приостановки и остановки работы.
Привязка была удалена, поскольку URB уже закреплен.
от первоначальной подачи, которая не сохраняется после первого возврата
побежал. Обнаружено XBOW, проверено Баулом Ли <baul.lee@xbow.com>
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: ALSA: us144mkii: re-anchor capture URBs on resubmission capture_urb_complete() resubmits each capture URB without anchoring it: usb_get_urb(urb); ret = usb_submit_urb(urb, GFP_ATOMIC); Anchoring is a property of a submission, not of the URB. The giveback path calls usb_unanchor_urb() before urb->complete(), so an URB resubmitted from its own completion handler is off the anchor. The capture URBs are anchored once, at stream start, so from the first completion onward tascam->capture_anchor is empty. tascam_free_urbs(), tascam_disconnect(), tascam_suspend() and the stop-work path all call usb_kill_anchored_urbs(&tascam->capture_anchor) to reap the capture URBs before anything is freed. With the anchor empty those calls return immediately and the URBs stay queued on the host controller. tascam_free_urbs() then returns the capture transfer buffers with usb_free_coherent(), and snd_card_free() releases the snd_card allocation that embeds tascam (card->private_data). The controller completes the queued URBs afterwards, writing device-supplied data into the freed transfer buffer, and capture_urb_complete() dereferences the freed driver object. KASAN on 7.2.0-rc5 (arm64): BUG: KASAN: slab-use-after-free in dummy_timer Write of size 512 at addr ffff000015b62000 __asan_memcpy dummy_timer hrtimer_run_softirq Allocated by task 64: usb_alloc_coherent tascam_alloc_urbs tascam_probe Freed by task 170: usb_free_coherent tascam_free_urbs tascam_disconnect usb_unbind_interface BUG: KASAN: slab-use-after-free in capture_urb_complete Read of size 4 at addr ffff0000170ee878 Freed by task 170: release_card_device snd_card_free tascam_disconnect Restore the usb_anchor_urb() between the reference count bump and the resubmission. That also makes the handler's usb_unanchor_urb() failure arm meaningful again and restores usb_kill_anchored_urbs() as a barrier on the disconnect, suspend and stop-work paths. The anchoring was removed on the premise that the URB is already anchored from the initial submission, which does not hold once the first giveback has run. Discovered by XBOW, triaged by Baul Lee <baul.lee@xbow.com>