В ядре Linux устранена следующая уязвимость:
perf/x86: исправлен доступ к событию NULL и возможная потеря записи PEBS. Когда вызывается intel_pmu_drain_pebs_icl() для очистки записей PEBS,
perf_event_overflow() может быть вызван для обработки последней записи PEBS. Хотя perf_event_overflow() может вызвать дросселирование прерывания и
остановить все события группы, как показано в приведенной ниже цепочке вызовов.
perf_event_overflow()
-> __perf_event_overflow()
->__perf_event_account_interrupt()
-> perf_event_throttle_group()
-> perf_event_throttle()
-> событие->pmu->стоп()
-> x86_pmu_stop()
Побочным эффектом остановки событий является то, что все соответствующие события
указатели в массиве cpuc->events[] очищаются до NULL.
Предположим, в группе есть два события PEBS (событие a и событие b). Когда
intel_pmu_drain_pebs_icl() вызывает perf_event_overflow() для обработки
последняя запись PEBS о событии PEBS a, срабатывает прерывание дроссельной заслонки и
все указатели событий a и b очищаются до NULL. Тогда
intel_pmu_drain_pebs_icl() пытается обработать последнюю запись PEBS
событие b и обнаруживает доступ к NULL-указателю.
Чтобы избежать этой проблемы, переместите очистку cpuc->events[] из x86_pmu_stop().
в x86_pmu_del(). Это безопасно, поскольку cpuc->active_mask или
cpuc->pebs_enabled всегда проверяется перед доступом к указателю событий.
из cpuc->events[].
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: perf/x86: Fix NULL event access and potential PEBS record loss When intel_pmu_drain_pebs_icl() is called to drain PEBS records, the perf_event_overflow() could be called to process the last PEBS record. While perf_event_overflow() could trigger the interrupt throttle and stop all events of the group, like what the below call-chain shows. perf_event_overflow() -> __perf_event_overflow() ->__perf_event_account_interrupt() -> perf_event_throttle_group() -> perf_event_throttle() -> event->pmu->stop() -> x86_pmu_stop() The side effect of stopping the events is that all corresponding event pointers in cpuc->events[] array are cleared to NULL. Assume there are two PEBS events (event a and event b) in a group. When intel_pmu_drain_pebs_icl() calls perf_event_overflow() to process the last PEBS record of PEBS event a, interrupt throttle is triggered and all pointers of event a and event b are cleared to NULL. Then intel_pmu_drain_pebs_icl() tries to process the last PEBS record of event b and encounters NULL pointer access. To avoid this issue, move cpuc->events[] clearing from x86_pmu_stop() to x86_pmu_del(). It's safe since cpuc->active_mask or cpuc->pebs_enabled is always checked before access the event pointer from cpuc->events[].