В ядре Linux устранена следующая уязвимость:
mm: исправлен UAF, когда vma->mm освобождается после удаления vma->vm_refcnt. Вызывая задержки в нужных местах, Ян Хорн создал репродуктор для
трудноразрешимая проблема UAF, которая стала возможной после того, как VMA было разрешено
переработаны путем добавления SLAB_TYPESAFE_BY_RCU в их кеш. Описание расы заимствовано из отчета Янна об открытии:
lock_vma_under_rcu() без блокировки ищет VMA с помощью mas_walk() под
rcu_read_lock().
В этот момент VMA может быть одновременно освобождена, и это
могут быть переработаны другим процессом. vma_start_read() затем увеличивает
vma->vm_refcnt (если оно находится в допустимом диапазоне), и если это удастся,
vma_start_read() может вернуть переработанный VMA. В этом сценарии, когда VMA был переработан, lock_vma_under_rcu()
затем обнаружит несоответствие указателя ->vm_mm и пропустит VMA через
vma_end_read(), который вызывает vma_refcount_put(). vma_refcount_put() удаляется
счетчик ссылок, а затем вызывает rcuwait_wake_up(), используя копию vma->vm_mm. Это неверно: неявно предполагается, что вызывающая сторона сохраняет имя VMA.
мм жив, но в этом случае звонящий не имеет отношения к мм ВМА,
поэтому rcuwait_wake_up() может вызвать UAF.
Схема, изображающая гонку:
Т1 Т2 Т3
== == ==
lock_vma_under_rcu
mas_walk
<VMA удаляется из мм>
ммап
<перераспределяется та же самая VMA>
vma_start_read
__refcount_inc_not_zero_limited_acquire
мунмап
__vma_enter_locked
refcount_add_not_zero
vma_end_read
vma_refcount_put
__refcount_dec_and_test
rcuwait_wait_event
<завершить операцию>
rcuwait_wake_up [УАФ]
Обратите внимание, что rcuwait_wait_event() в T3 не блокируется, поскольку refcount был
уже упал на T1. В этот момент T3 может выйти и освободить мм, вызывая
ВСУ в Т1. Чтобы избежать этого, мы перемещаем проверку vma->vm_mm в vma_start_read() и
захватите vma->vm_mm, чтобы стабилизировать его перед операцией vma_refcount_put().
[surenb@google.com: v3]
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: mm: fix a UAF when vma->mm is freed after vma->vm_refcnt got dropped By inducing delays in the right places, Jann Horn created a reproducer for a hard to hit UAF issue that became possible after VMAs were allowed to be recycled by adding SLAB_TYPESAFE_BY_RCU to their cache. Race description is borrowed from Jann's discovery report: lock_vma_under_rcu() looks up a VMA locklessly with mas_walk() under rcu_read_lock(). At that point, the VMA may be concurrently freed, and it can be recycled by another process. vma_start_read() then increments the vma->vm_refcnt (if it is in an acceptable range), and if this succeeds, vma_start_read() can return a recycled VMA. In this scenario where the VMA has been recycled, lock_vma_under_rcu() will then detect the mismatching ->vm_mm pointer and drop the VMA through vma_end_read(), which calls vma_refcount_put(). vma_refcount_put() drops the refcount and then calls rcuwait_wake_up() using a copy of vma->vm_mm. This is wrong: It implicitly assumes that the caller is keeping the VMA's mm alive, but in this scenario the caller has no relation to the VMA's mm, so the rcuwait_wake_up() can cause UAF. The diagram depicting the race: T1 T2 T3 == == == lock_vma_under_rcu mas_walk <VMA gets removed from mm> mmap <the same VMA is reallocated> vma_start_read __refcount_inc_not_zero_limited_acquire munmap __vma_enter_locked refcount_add_not_zero vma_end_read vma_refcount_put __refcount_dec_and_test rcuwait_wait_event <finish operation> rcuwait_wake_up [UAF] Note that rcuwait_wait_event() in T3 does not block because refcount was already dropped by T1. At this point T3 can exit and free the mm causing UAF in T1. To avoid this we move vma->vm_mm verification into vma_start_read() and grab vma->vm_mm to stabilize it before vma_refcount_put() operation. [surenb@google.com: v3]
Характеристики атаки
Последствия
Строка CVSS v3.1
Тип уязвимости (CWE)
Уязвимые продукты 2
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.15
|
6.15.10
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.16
|
6.16.1
|