В ядре Linux устранена следующая уязвимость:
трассировка: исправлено использование после освобождения с триггерами с одинаковыми именами. Когда два триггера статистики по разным событиям регистрируются с одним и тем же
name=, второй повторно использует первый как именованные_данные. Оба добавлены в
tr->hist_vars с помощью save_hist_vars() во время event_hist_trigger_parse(),
потому что save_hist_vars() вызывается перед event_trigger_register(), а
именованное повторное использование обнаруживается только позже, в hist_register_trigger().
Затем в ветке именованных данных hist_register_trigger() освобождает второй
hist_data гистограммы через Destroy_hist_data(), но никогда не удаляет его
запись списка tr->hist_vars, оставляя висячий указатель и утечку
Ссылка на трассировку_массива, которую он содержит. Более поздний триггер истории, который ссылается на переменную, делает find_var_file()
пройдите tr->hist_vars и разыменуйте освобожденные hist_data. Ошибка
воспроизводимо из пользовательского пространства путем записи трех триггеров истории в трассировку:
компакт-диск /sys/ядро/трассировка
echo 'hist:keys=common_pid:x=common_pid:name=mh' > события/sched/sched_switch/trigger
echo 'hist:keys=common_pid:x=common_pid:name=mh' > события/sched/sched_process_fork/trigger
echo 'hist:keys=common_pid:vals=$x' > события/sched/sched_process_exit/триггер
Третья запись приводит к панике ядра:
ОШИБКА: KASAN: slab-use-after-free в find_var_file.part.0+0x272/0x290
Чтение размера 8 по адресу ffff888001f8a0e0 с помощью задачи sh/1.
ЦП: 1 UID: 0 PID: 1 Связь: sh Испорченный: G D N
Отслеживание вызова:
find_var_file.part.0
find_event_var
parse_atom
parse_expr
__create_val_field
event_hist_trigger_parse
триггер_процесс_регулярное выражение
event_trigger_write
vfs_write
ksys_write
do_syscall_64
запись_SYSCALL_64_after_hwframe
Выделено по задаче 1:
event_hist_trigger_parse
Освобожден заданием 1:
hist_register_trigger+0x618/0xa30
event_hist_trigger_parse
Глючный адрес принадлежит освобожденной 2048-байтовой области. Упс: общая ошибка защиты... RIP: find_var_file.part.0
Паника ядра – не синхронизируется: попытка убить init! код выхода = 0x0000000b
Исправьте это, удалив hist_data из tr->hist_vars и освободив
Ссылка на трассировку_массива в ветке именованных данных hist_register_trigger()
перед освобождением hist_data.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: tracing: Fix use-after-free with same-name named triggers When two hist triggers on different events are registered with the same name=, the second one reuses the first as named_data. Both are added to tr->hist_vars by save_hist_vars() during event_hist_trigger_parse(), because save_hist_vars() is called before event_trigger_register() while the named reuse is only detected later, in hist_register_trigger(). In the named-data branch hist_register_trigger() then frees the second histogram's hist_data via destroy_hist_data(), but never removes its tr->hist_vars list entry, leaving a dangling pointer and leaking the trace_array reference it holds. A later hist trigger that references a variable makes find_var_file() walk tr->hist_vars and dereference the freed hist_data. The bug is reproducible from userspace by writing three hist triggers to tracefs: cd /sys/kernel/tracing echo 'hist:keys=common_pid:x=common_pid:name=mh' > events/sched/sched_switch/trigger echo 'hist:keys=common_pid:x=common_pid:name=mh' > events/sched/sched_process_fork/trigger echo 'hist:keys=common_pid:vals=$x' > events/sched/sched_process_exit/trigger The third write panics the kernel: BUG: KASAN: slab-use-after-free in find_var_file.part.0+0x272/0x290 Read of size 8 at addr ffff888001f8a0e0 by task sh/1 CPU: 1 UID: 0 PID: 1 Comm: sh Tainted: G D N Call Trace: find_var_file.part.0 find_event_var parse_atom parse_expr __create_val_field event_hist_trigger_parse trigger_process_regex event_trigger_write vfs_write ksys_write do_syscall_64 entry_SYSCALL_64_after_hwframe Allocated by task 1: event_hist_trigger_parse Freed by task 1: hist_register_trigger+0x618/0xa30 event_hist_trigger_parse The buggy address belongs to freed 2048-byte region Oops: general protection fault ... RIP: find_var_file.part.0 Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b Fix by removing the hist_data from tr->hist_vars and releasing the trace_array reference in the named-data branch of hist_register_trigger() before freeing the hist_data.
Характеристики атаки
Последствия
Строка CVSS v3.1
Уязвимые продукты 7
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.12.18
|
6.12.109
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.14
|
6.18.50
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.14
|
7.2.4
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.14
|
7.3-rc1
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.1.130
|
— |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.6.81
|
— |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.13.6
|
— |