linux-stable/kernel/events
Song Liu f6b5d51976 perf: Fix list corruption in perf_cgroup_switch()
commit 5f4e5ce638 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: 058fe1c044 ("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:54:31 +01:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
callchain.c uaccess: add force_uaccess_{begin,end} helpers 2020-08-12 10:57:59 -07:00
core.c perf: Fix list corruption in perf_cgroup_switch() 2022-02-16 12:54:31 +01:00
hw_breakpoint.c powerpc/watchpoint: Don't allow concurrent perf and ptrace events 2020-05-19 00:14:45 +10:00
internal.h perf: Optimize get_recursion_context() 2020-11-09 18:12:34 +01:00
ring_buffer.c perf: Reduce stack usage of perf_output_begin() 2020-11-09 18:12:33 +01:00
uprobes.c kernel: delete repeated words in comments 2022-02-01 17:25:45 +01:00