В ядре Linux устранена следующая уязвимость:
ipv6: Anycast: вставить ACA в глобальный хэш под idev->lock
syzbot сообщил о сплате [1]: slab-use-after-free в
ipv6_chk_acast_addr(), который просматривает глобальный хеш inet6_acaddr_lst[]
под RCU и разыменовывает структуру ifacaddr6, которая уже была
освобождается, хотя он все еще связан с хэшем, поэтому последующий читатель попадает в
болтающийся узел. В __ipv6_dev_ac_inc() aca выделяется с refcount 1, затем
aca_get() увеличивает его до 2, чтобы сохранить его активность в разблокированной области. Он публикуется в idev->ac_list под idev->lock, но
ipv6_add_acaddr_hash() запускается после write_unlock_bh().
Параллельный
демонтаж (ipv6_ac_destroy_dev() из addrconf_ifdown(), под RTNL)
может проскользнуть в это окно:
CPU0 __ipv6_dev_ac_inc CPU1 ipv6_ac_destroy_dev (RTNL)
------------------------------ ------------------------------------
aca_alloc() ссылка 1
aca_get() ссылка 2
write_lock_bh(idev->блокировка)
добавить ACA в ac_list
write_unlock_bh (idev-> блокировка)
write_lock_bh(idev->блокировка)
извлечь aca из ac_list
write_unlock_bh (idev-> блокировка)
ipv6_del_acaddr_hash (ака)
hlist_del_init_rcu() не работает,
ака еще нет в хеше
aca_put() ссылка 2->1
ipv6_add_acaddr_hash (ака)
aca теперь вставлен в хэш
aca_put() ссылка 1->0
call_rcu(aca_free_rcu) -> kfree(aca)
Удаление хэша становится невозможным, поскольку вставка не
еще не произошло, поэтому как только CPU0 вставит и удалит последнюю ссылку,
aca освобождается, хотя он все еще связан с inet6_acaddr_lst[], и читатели
разыменование освобождает память после повторного использования слота пластины. Это окно открылось после того, как RTNL прекратил сериализацию пути соединения.
демонтаж устройства. Переместите ipv6_add_acaddr_hash() внутри idev->lock.
раздел, поэтому вставки ac_list и хеша являются атомарными по отношению к
демонтаж: гоночный ремувер теперь либо полностью пропускает ака, либо находит
это в обоих списках.
acaddr_hash_lock теперь вложен в idev->lock, который получается в
контекст softirq, поэтому переключите все сайты acaddr_hash_lock на spin_lock_bh()
чтобы избежать инверсии блокировки irq, описанной в [2].
[1] https://syzkaller.appspot.com/bug?extid=a01df04303c131efbf3a
[2] https://lore.kernel.org/netdev/6a194ef7.ba3b1513.1890b4.0000.GAE@google.com/
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: ipv6: anycast: insert aca into global hash under idev->lock syzbot reported a splat [1]: a slab-use-after-free in ipv6_chk_acast_addr(), which walks the global inet6_acaddr_lst[] hash under RCU and dereferences a struct ifacaddr6 that has already been freed while still linked in the hash, so a later reader walks into a dangling node. In __ipv6_dev_ac_inc() the aca is allocated with refcount 1, then aca_get() bumps it to 2 to keep it alive across the unlocked region. It is published to idev->ac_list under idev->lock, but ipv6_add_acaddr_hash() runs after write_unlock_bh(). A concurrent teardown (ipv6_ac_destroy_dev() from addrconf_ifdown(), under RTNL) can slip into that window: CPU0 __ipv6_dev_ac_inc CPU1 ipv6_ac_destroy_dev (RTNL) ------------------------------ ------------------------------------ aca_alloc() refcnt 1 aca_get() refcnt 2 write_lock_bh(idev->lock) add aca to ac_list write_unlock_bh(idev->lock) write_lock_bh(idev->lock) pull aca off ac_list write_unlock_bh(idev->lock) ipv6_del_acaddr_hash(aca) hlist_del_init_rcu() is a no-op, aca is not in the hash yet aca_put() refcnt 2->1 ipv6_add_acaddr_hash(aca) aca now inserted into the hash aca_put() refcnt 1->0 call_rcu(aca_free_rcu) -> kfree(aca) The hash removal becomes a no-op because the insertion has not happened yet, so once CPU0 inserts and drops the last reference, the aca is freed while still linked in inet6_acaddr_lst[], and readers dereference freed memory after the slab slot is reused. This window opened once RTNL stopped serializing the join path against device teardown. Move ipv6_add_acaddr_hash() inside the idev->lock section so the ac_list and hash insertions are atomic with respect to teardown: a racing remover now either misses the aca entirely or finds it in both lists. acaddr_hash_lock is now nested under idev->lock, which is acquired in softirq context, so switch all acaddr_hash_lock sites to spin_lock_bh() to avoid the irq lock inversion reported in [2]. [1] https://syzkaller.appspot.com/bug?extid=a01df04303c131efbf3a [2] https://lore.kernel.org/netdev/6a194ef7.ba3b1513.1890b4.0000.GAE@google.com/
Характеристики атаки
Последствия
Строка CVSS v3.1
Тип уязвимости (CWE)
Уязвимые продукты 8
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.17
|
6.18.36
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.19
|
7.0.13
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:7.1:rc1:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:7.1:rc2:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:7.1:rc3:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:7.1:rc4:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:7.1:rc5:*:*:*:*:*:*
|
— | — |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:7.1:rc6:*:*:*:*:*:*
|
— | — |