]> git.baikalelectronics.ru Git - kernel.git/commit
perf: Fix list corruption in perf_cgroup_switch()
authorSong Liu <song@kernel.org>
Fri, 4 Feb 2022 00:40:57 +0000 (16:40 -0800)
committerPeter Zijlstra <peterz@infradead.org>
Sun, 6 Feb 2022 21:37:27 +0000 (22:37 +0100)
commitfe99d64de70170b5260914dbaf997ed11feaf145
treee1b716c4008595ffb28775f1357d8da88414befc
parent00bf39749b0f7f81d206fb37e2c6a43033e5ebbf
perf: Fix list corruption in perf_cgroup_switch()

There's list corruption on cgrp_cpuctx_list. This happens on the
following path:

  perf_cgroup_switch: list_for_each_entry(cgrp_cpuctx_list)
      cpu_ctx_sched_in
         ctx_sched_in
            ctx_pinned_sched_in
              merge_sched_in
                  perf_cgroup_event_disable: remove the event from the list

Use list_for_each_entry_safe() to allow removing an entry during
iteration.

Fixes: 970189a32205 ("perf/core: Make cgroup switch visit only cpuctxs with cgroup events")
Signed-off-by: Song Liu <song@kernel.org>
Reviewed-by: Rik van Riel <riel@surriel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220204004057.2961252-1-song@kernel.org
kernel/events/core.c