В ядре Linux устранена следующая уязвимость:
perf/x86/amd/brs: исправлена утечка адреса ядра. Стек ветвей, доступный только пользователю, может содержать ветки, происходящие от
ядро. В результате адреса ядра становятся доступными для пользовательского пространства.
даже когда запрашивается PERF_SAMPLE_BRANCH_USER.
На процессорах AMD
поддержка X86_FEATURE_BRS (только для Zen 3), perf по-прежнему может сообщать записи
такие как SYSRET/возвраты прерываний, для которых адреса перехода
находятся в ядре. Например.
$ perf Record -j Any,u -c 4000 -e Branch-Brs -o - -- \
системный вызов perf Bench Basic --loop 1000 | \
perf script -i - -F brstack|tr ' ' '\n'| \
grep -E '0x[89a-f][0-9a-f]{15}'
...
0xffffffff810001c4/0x72e2e32955eb/-/-/-/0//-
0xffffffff810001c4/0x72e2d94a9821/-/-/-/0//-
0xffffffff810001c4/0x72e2d94ffa1b/-/-/-/0//-
... BRS не обеспечивает аппаратную фильтрацию ветвей, поэтому уровень привилегий
фильтрация полностью выполняется программно.
Однако amd_brs_match_plm()
только проверяет адрес перехода на соответствие запрошенной привилегии
уровни. Для ветвей из ядра в пространство пользователя параметр ветвления из
адрес остается непроверенным и становится доступным. Расширьте программный фильтр, чтобы
также проверьте адрес перехода, чтобы любая запись ветки, чья
Адрес ветки, находящийся в ядре, удаляется, когда
Запрошен PERF_SAMPLE_BRANCH_USER.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: perf/x86/amd/brs: Fix kernel address leakage A user-only branch stack can contain branches that originate from the kernel. As a result, kernel addresses are exposed to user space even when PERF_SAMPLE_BRANCH_USER is requested. On AMD processors supporting X86_FEATURE_BRS (Zen 3 only), perf can still report entries such as SYSRET/interrupt returns for which the branch-from addresses are in the kernel. E.g. $ perf record -j any,u -c 4000 -e branch-brs -o - -- \ perf bench syscall basic --loop 1000 | \ perf script -i - -F brstack|tr ' ' '\n'| \ grep -E '0x[89a-f][0-9a-f]{15}' ... 0xffffffff810001c4/0x72e2e32955eb/-/-/-/0//- 0xffffffff810001c4/0x72e2d94a9821/-/-/-/0//- 0xffffffff810001c4/0x72e2d94ffa1b/-/-/-/0//- ... BRS provides no hardware branch filtering, so privilege level filtering is performed entirely in software. However, amd_brs_match_plm() only validates the branch-to address against the requested privilege levels. For branches from the kernel to user space, the branch-from address is left unchecked and is leaked. Extend the software filter to also validate the branch-from address, so that any branch record whose branch-from address is in the kernel is dropped when PERF_SAMPLE_BRANCH_USER is requested.