Skip to content

Commit f5e0265

Browse files
committed
Merge tag 'perf_urgent_for_v5.17_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fix from Borislav Petkov: "Prevent cgroup event list corruption when switching events" * tag 'perf_urgent_for_v5.17_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf: Fix list corruption in perf_cgroup_switch()
2 parents 808f0ab + 5f4e5ce commit f5e0265

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/events/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ static DEFINE_PER_CPU(struct list_head, cgrp_cpuctx_list);
839839
*/
840840
static void perf_cgroup_switch(struct task_struct *task, int mode)
841841
{
842-
struct perf_cpu_context *cpuctx;
842+
struct perf_cpu_context *cpuctx, *tmp;
843843
struct list_head *list;
844844
unsigned long flags;
845845

@@ -850,7 +850,7 @@ static void perf_cgroup_switch(struct task_struct *task, int mode)
850850
local_irq_save(flags);
851851

852852
list = this_cpu_ptr(&cgrp_cpuctx_list);
853-
list_for_each_entry(cpuctx, list, cgrp_cpuctx_entry) {
853+
list_for_each_entry_safe(cpuctx, tmp, list, cgrp_cpuctx_entry) {
854854
WARN_ON_ONCE(cpuctx->ctx.nr_cgroups == 0);
855855

856856
perf_ctx_lock(cpuctx, cpuctx->task_ctx);

0 commit comments

Comments
 (0)