OpenCloudOS-Kernel/kernel/events
Peter Zijlstra 1e450e34ef perf: Fix sys_perf_event_open() race against self
commit 3ac6487e58 upstream.

Norbert reported that it's possible to race sys_perf_event_open() such
that the looser ends up in another context from the group leader,
triggering many WARNs.

The move_group case checks for races against itself, but the
!move_group case doesn't, seemingly relying on the previous
group_leader->ctx == ctx check. However, that check is racy due to not
holding any locks at that time.

Therefore, re-check the result after acquiring locks and bailing
if they no longer match.

Additionally, clarify the not_move_group case from the
move_group-vs-move_group race.

Fixes: f63a8daa58 ("perf: Fix event->ctx locking")
Reported-by: Norbert Slusarek <nslusarek@gmx.net>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Tao Wu <tallwu@tencent.com>
Reviewed-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 20:41:41 +08: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 ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
core.c perf: Fix sys_perf_event_open() race against self 2024-06-11 20:41:41 +08:00
hw_breakpoint.c perf/hw_breakpoint: Fix arch_hw_breakpoint use-before-initialization 2019-09-06 08:24:01 +02:00
internal.h ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
ring_buffer.c perf/ring-buffer: Use regular variables for nesting 2019-05-24 09:00:11 +02:00
uprobes.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00