В ядре Linux устранена следующая уязвимость:
RDMA/ucma: заблокируйте обработчик в ucma_write_cm_event(). Файл ctx->можно изменить только при блокировке обработчика и xa_lock, что
это то, что останавливает постановку событий в очередь для ctx во время перемещения ucma_migrate_id()
его в другой файл. Ядро CM принимает эту блокировку перед вызовом
ucma_event_handler(), но пути write(), которые сами ставят в очередь события
нет.
ucma_write_cm_event() перечитывает файл ctx->для каждого из четырех его разыменований,
поэтому ucma_migrate_id() может поменять его местами в середине последовательности:
mutex_lock(&ctx->file->mut); /* файл А */
list_add_tail(&uevent->list, &ctx->file->event_list); /* файл Б */
mutex_unlock(&ctx->file->mut); /* файл Б */
Wake_up_interruptible(&ctx->file->poll_wait); /* файл Б */
Окно — это сама функция mutex_lock(): записывающий элемент спит в нем, пока
миграция переназначает ctx->file.
Затем list_add_tail() запускается для файла B.
event_list, содержащий только мьютекс файла A:
list_add повреждение. предыдущее->следующее должно быть следующим (ffff888101320f30),
но был ffff88814a08c418. (предыдущий=ffff88814a075c18). ОШИБКА ядра в lib/list_debug.c:32!
Отслеживание вызова:
ucma_write_cm_event+0x36e/0x5e0
и mut файла A остается удерживаемым навсегда, переводя следующую запись в состояние D. Событие uevent также застряло в списке. ucma_cleanup_ctx_events() не будет
walk, поэтому он переживает свой контекст. /dev/infiniband/rdma_cm — 0666 и нет
Задействуется RDMA-устройство, поэтому ко всему этому имеет доступ непривилегированный пользователь.
Возьмите блокировку обработчика, как это делает ucma_cleanup_mc_events(); ctx->cm_id это
закреплено ссылкой ucma_get_ctx().
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: RDMA/ucma: Lock the handler in ucma_write_cm_event() ctx->file may only be changed under the handler lock and the xa_lock, which is what stops uevents being queued for a ctx while ucma_migrate_id() moves it to another file. The CM core takes that lock before invoking ucma_event_handler(), but the write() paths that queue uevents themselves do not. ucma_write_cm_event() re-reads ctx->file for each of its four dereferences, so ucma_migrate_id() can swap it mid-sequence: mutex_lock(&ctx->file->mut); /* file A */ list_add_tail(&uevent->list, &ctx->file->event_list); /* file B */ mutex_unlock(&ctx->file->mut); /* file B */ wake_up_interruptible(&ctx->file->poll_wait); /* file B */ The window is the mutex_lock() itself: the writer sleeps in it while the migration reassigns ctx->file. The list_add_tail() then runs on file B's event_list holding only file A's mutex: list_add corruption. prev->next should be next (ffff888101320f30), but was ffff88814a08c418. (prev=ffff88814a075c18). kernel BUG at lib/list_debug.c:32! Call Trace: ucma_write_cm_event+0x36e/0x5e0 and file A's mut is left held forever, wedging its next writer in D state. The uevent is also stranded on a list ucma_cleanup_ctx_events() will not walk, so it outlives its context. /dev/infiniband/rdma_cm is 0666 and no RDMA device is involved, so an unprivileged user reaches all of this. Take the handler lock, as ucma_cleanup_mc_events() does; ctx->cm_id is pinned by the ucma_get_ctx() reference.
Характеристики атаки
Последствия
Строка CVSS v3.1