Song Liu 30d9f3cbe4 perf: Fix list corruption in perf_cgroup_switch()
commit 5f4e5ce638e6a490b976ade4a40017b40abb2da0 upstream.

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: 058fe1c0440e ("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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-02-16 12:51:47 +01:00
..
2020-09-17 13:45:31 +02:00
2019-12-13 08:51:11 +01:00
2019-12-01 09:17:17 +01:00
2021-07-20 16:16:04 +02:00
2021-02-10 09:21:06 +01:00
2020-03-25 08:06:13 +01:00
2019-01-13 09:51:06 +01:00
2021-02-07 14:48:38 +01:00
2020-01-09 10:18:59 +01:00