В ядре Linux была устранена следующая уязвимость: мм/км: сброс нестабильных деревьев всех узлов Each полное сканирование сбрасывает нестабильные корни деревьев ksm_nr_node_ids. Включение merge_across_nodes сбрасывает это количество до 1, даже если корневые узлы были ранее выделены. Таким образом, при переключении "merge_across_nodes" 0 -> 1 -> 0, сканирование, которое начинается при настройке 1 и продолжается после переключения обратно на 0, может столкнуться с устаревшими нестабильными корнями деревьев, в результате чего UAF.
Только root может изменить "merge_across_nodes", а документированная последовательность такова: "merge_across_nodes установка может быть изменена только тогда, когда в системе нет общих страниц ksm: сначала установите запуск 2 для отсоединения страниц, затем 1 после изменения merge_across_nodes, чтобы восстановить в соответствии с новой настройкой." Let's исправить, отслеживая в ksm_nr_node_ids фактическое количество выделенных корней дерева. remove_all_stable_nodes() и ksm_check_stable_tree07() теперь будут сканивать больше.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: mm/ksm: reset the unstable trees of all nodes Each full scan resets ksm_nr_node_ids unstable tree roots. Enabling merge_across_nodes resets this count to 1, even if per-node roots were previously allocated. So when toggling "merge_across_nodes" 0 -> 1 -> 0, a scan that starts while the setting is 1 and continues after switching back to 0 can encounter stale unstable tree roots, resulting in UAF. Only root is allowed to change "merge_across_nodes", and the documented sequence is: "merge_across_nodes setting can be changed only when there are no ksm shared pages in the system: set run 2 to unmerge pages first, then to 1 after changing merge_across_nodes, to remerge according to the new setting." Let's fix it by tracking in ksm_nr_node_ids the actual number of allocated tree roots. remove_all_stable_nodes() and ksm_check_stable_tree() will now scan more tree roots (skipping the empty ones), which is harmless.