В ядре Linux была устранена следующая уязвимость: ALSA: usx2y: Require буфер из двух URBs usx2y_urb_capt_retire() обматывает буфер кольца один раз за пакет и usx2y_urb_play_prepare() один раз за URB пакетов nr_of_packs() размером до 50 кадров. Оба предполагают, что данные помещаются в буфер, и ограничения hw требуют только около двух периодов 1 мс, поэтому пакет больше, чем буфер при захвате, или URB больше, чем буфер при воспроизведении, нарушает это предположение. Ограничьте SNDRV_PCM_HW_PARAM_BUFFER_SIZE в snd_usx2y_pcm_open() по крайней мере двумя URBs, 2 * nr_of_packs() * 50 кадрами, для обоих направлений.
Граница находится в кадрах и выводится из собственного лимита пакетов драйвера, поэтому она не читает конечную точку, чей альтсеттинг выбирается только в prepar. Два URBs, а не один, потому что позиция продвигается URB по воспроизведению и движется только тогда, когда URB меньше, чем весь буфер. Храните в usx2y_urb_capt_retire() защитное ограждение, которое падает на пакет больше, чем буфер, в случае, если ограничение делает недоступным.
С nrpacks выше около 163 (S16_LE) или 109 (S24_3LE) граница превышает 64 KiB буфера подпотока preallocates (дважды, что с предварительным распределением, поднятым до его 128 KiB максимум), так что hw_params терпит неудачу для этих параметров модуля. Это означает, что водитель не может быть в безопасности с URB, превышающим половину самого большого буфера. Воспроизводится на 7.3-rc7 с USB/IP устройством, представляющим схему интерфейса US-122 и 1024-байтные пакеты в 512-байтный буфер захвата: BUG: KASAN: out-of-bounds в i_usx2y_urb_complete+0x1285/0x1ac0 Read размера 184467443709551104 в адре ffff88800e448800 по задаче vhci_rx/83 Tested на 7.3-rc7 с тем же устройством, S16_LE в 44100 Hz, nrpacks 4, так что граница составляет 400 кадров. 128-кадровый буфер захвата и 200-кадровый буфер воспроизведения отклоняются в hw_params с EINVAL. 400-кадровый буферный поток в течение 30 секунд в каждом направлении с позицией, продвигающейся внутри буфера, и без отчета KASAN; охранник захвата не стрелял.
Тот же 400-кадровый буфер захвата с S24_3LE, который выбирает альтсет 2 в подготовке, потоки для 30 с с тем же результатом.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: ALSA: usx2y: Require a buffer of two URBs usx2y_urb_capt_retire() wraps the ring buffer once per packet and usx2y_urb_play_prepare() once per URB of nr_of_packs() packets of up to 50 frames. Both assume that the data fits in the buffer, and the hw constraints only require about two 1 ms periods, so a packet larger than the buffer on capture, or a URB larger than the buffer on playback, violates that assumption. Constrain SNDRV_PCM_HW_PARAM_BUFFER_SIZE in snd_usx2y_pcm_open() to at least two URBs, 2 * nr_of_packs() * 50 frames, for both directions. The bound is in frames and derived from the driver's own packet limit, so it does not read the endpoint, whose altsetting is only selected in prepare. Two URBs rather than one, because the position advances by a URB on playback and only moves when a URB is less than the whole buffer. Keep a guard in usx2y_urb_capt_retire() that drops a packet larger than the buffer, for the case the constraint makes unreachable. With nrpacks above about 163 (S16_LE) or 109 (S24_3LE) the bound exceeds the 64 KiB buffer the substream preallocates (twice that with the preallocation raised to its 128 KiB maximum), so hw_params fails for those module settings. That is intended: the driver cannot be safe with a URB larger than half the largest buffer. Reproduced on 7.3-rc7 with a USB/IP device presenting the US-122 interface layout and 1024-byte packets into a 512-byte capture buffer: BUG: KASAN: out-of-bounds in i_usx2y_urb_complete+0x1285/0x1ac0 Read of size 18446744073709551104 at addr ffff88800e448800 by task vhci_rx/83 Tested on 7.3-rc7 with the same device, S16_LE at 44100 Hz, nrpacks 4, so the bound is 400 frames. A 128-frame capture buffer and a 200-frame playback buffer are refused at hw_params with EINVAL. A 400-frame buffer streams for 30 s in each direction with the position advancing inside the buffer and no KASAN report; the capture guard did not fire. The same 400-frame capture buffer with S24_3LE, which selects altsetting 2 in prepare, streams for 30 s with the same result.
Характеристики атаки
Последствия
Строка CVSS v3.1