В ядре Linux устранена следующая уязвимость:
io_uring/zcrx: исправлена гонка user_ref между путями очистки и пополнения. Функция io_zcrx_put_niov_uref() использует неатомарный
шаблон «проверь, затем уменьши» (atomic_read, за которым следует отдельный
atomic_dec) для управления user_refs. Это сериализуется против других
вызывающие абоненты с помощью rq_lock, но io_zcrx_scrub() изменяет тот же счетчик с помощью
atomic_xchg() БЕЗ удержания rq_lock.
В системах SMP существует следующая раса:
CPU0 (пополнение, сохраняется rq_lock) CPU1 (очистка, без rq_lock)
put_niov_uref:
atomic_read(uref) - 1
// окно открывается
atomic_xchg(uref, 0) - 1
return_niov_freelist(niov) [НАЖМИТЕ #1]
// окно закрывается
atomic_dec(uref) — переводится в -1
возвращает истину
return_niov(ниов)
return_niov_freelist(niov) [НАЖМИТЕ #2: ДВОЙНОЙ БЕСПЛАТНО]
Один и тот же niov дважды помещается в список свободных, в результате чего free_count
превышать nr_iovs. Последующие нажатия свободных списков затем выполняют выход за пределы
записать (значение u32) за массив свободных списков kvmalloc в соседний
плитный объект. Исправьте это, заменив неатомарную команду read-then-dec в
io_zcrx_put_niov_uref() с цикломatomic_try_cmpxchg, который атомарно
проверяет и уменьшает user_refs.
Это делает операцию безопасной
одновременный атомный_xchg из скраба без необходимости получения скраба
rq_lock.
[павел: удалил предупреждение и комментарий]
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: io_uring/zcrx: fix user_ref race between scrub and refill paths The io_zcrx_put_niov_uref() function uses a non-atomic check-then-decrement pattern (atomic_read followed by separate atomic_dec) to manipulate user_refs. This is serialized against other callers by rq_lock, but io_zcrx_scrub() modifies the same counter with atomic_xchg() WITHOUT holding rq_lock. On SMP systems, the following race exists: CPU0 (refill, holds rq_lock) CPU1 (scrub, no rq_lock) put_niov_uref: atomic_read(uref) - 1 // window opens atomic_xchg(uref, 0) - 1 return_niov_freelist(niov) [PUSH #1] // window closes atomic_dec(uref) - wraps to -1 returns true return_niov(niov) return_niov_freelist(niov) [PUSH #2: DOUBLE-FREE] The same niov is pushed to the freelist twice, causing free_count to exceed nr_iovs. Subsequent freelist pushes then perform an out-of-bounds write (a u32 value) past the kvmalloc'd freelist array into the adjacent slab object. Fix this by replacing the non-atomic read-then-dec in io_zcrx_put_niov_uref() with an atomic_try_cmpxchg loop that atomically tests and decrements user_refs. This makes the operation safe against concurrent atomic_xchg from scrub without requiring scrub to acquire rq_lock. [pavel: removed a warning and a comment]
Характеристики атаки
Последствия
Строка CVSS v3.1
Тип уязвимости (CWE)
Уязвимые продукты 2
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.15
|
6.18.16
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.19
|
6.19.6
|