В ядре Linux была устранена следующая уязвимость: rtnetlink: wait for RCU readers in rtnl_link_unregister() rtnl_link_ops_get() finds ops on link_ops under rcu_read_lock() и только после этого принимает ops->srcu. rtnl_link_unregister() unlinks ops, затем вызывает synchronize_srcu() и cleanup_srcu_struct() не дожидая RCU readition. Читатель, который нашел операции до list_del_rcu() и еще не взял ops->srcu, не ждет. Такой читатель затем блокирует очищенный srcu_struct и продолжает использовать операции после того, как модуль, которому он принадлежит, исчез. rtnl_newlink () и rtnl_dump_ifinfo () оба ищут операции без RTNL, последний для любого пользователя, который сбрасывает ссылки, отфильтрованные по виду.
С задержками, добавленными между поиском и srcu_read_lock() в rtnl_link_ops_get(), и до rtnl_link_ops_put() в rtnl_dump_ifinfo(), запуск "ip link show type duke" вместе с "rmmod duke" на ядре KASAN дает: BUG: KASAN: vmalloc-out-of-bounds в __srcu_read_unlock+0x57/0x70 Read размера 8 в addr ffffffffc02ff318 по задаче ip/147 Call Trace: __srcu_read_unlock+0x57/0x70 rtnl_dump_ifinfo.cold+0x30/0x3b rtnl_dumpit+0x7a/0x1b0 netlink_dump+0x486/0x11b0 __netlink_dump_start+0x661/0x910 rtnetlink_rcv_msg+0x611/0x9e0 netlink_rcv_skb+0x126/0x380 netlink_unicast+0x605/0x830 netlink_sendmsg+0x6d0/0xbb0 __sys_sendto+0x335/0x3a0 Call synchronize_rcu() до synchronize_srcu(), как rtnl_af_unregister() уже делает. Этого должно быть достаточно, потому что rtnl_link_ops_get() является единственным RCU ходоком link_ops, и он занимает ops->srcu до rcu_read_unlock(), поэтому каждый читатель, который нашел операции, покрывается synchronize_srcu(), как только заканчивается льготный период RCU. Дополнительный льготный период стоит времени только при разгрузке модуля.
Читатели и писатель были сериализованы RTNL, пока link_ops не получил свой собственный мьютекс, поэтому недостающее ожидание RCU не имело значения раньше.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: rtnetlink: wait for RCU readers in rtnl_link_unregister() rtnl_link_ops_get() finds ops on link_ops under rcu_read_lock() and only then takes ops->srcu. rtnl_link_unregister() unlinks ops, then calls synchronize_srcu() and cleanup_srcu_struct() without first waiting for RCU readers. A reader that found ops before list_del_rcu() and has not yet taken ops->srcu is not waited for. Such a reader then locks a cleaned-up srcu_struct and keeps using ops after the module that owns it is gone. rtnl_newlink() and rtnl_dump_ifinfo() both look up ops without RTNL, the latter for any user that dumps links filtered by kind. With delays added between the lookup and srcu_read_lock() in rtnl_link_ops_get(), and before rtnl_link_ops_put() in rtnl_dump_ifinfo(), running "ip link show type dummy" alongside "rmmod dummy" on a KASAN kernel gives: BUG: KASAN: vmalloc-out-of-bounds in __srcu_read_unlock+0x57/0x70 Read of size 8 at addr ffffffffc02ff318 by task ip/147 Call Trace: __srcu_read_unlock+0x57/0x70 rtnl_dump_ifinfo.cold+0x30/0x3b rtnl_dumpit+0x7a/0x1b0 netlink_dump+0x486/0x11b0 __netlink_dump_start+0x661/0x910 rtnetlink_rcv_msg+0x611/0x9e0 netlink_rcv_skb+0x126/0x380 netlink_unicast+0x605/0x830 netlink_sendmsg+0x6d0/0xbb0 __sys_sendto+0x335/0x3a0 Call synchronize_rcu() before synchronize_srcu(), as rtnl_af_unregister() already does. This should be enough because rtnl_link_ops_get() is the only RCU walker of link_ops, and it takes ops->srcu before rcu_read_unlock(), so every reader that found ops is covered by synchronize_srcu() once the RCU grace period ends. The extra grace period only costs time at module unload. Readers and the writer were serialized by RTNL until link_ops got its own mutex, which is why the missing RCU wait did not matter before.
Характеристики атаки
Последствия
Строка CVSS v3.1