Commit 5bdcf114 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Yongqiang Liu
Browse files

perf: Fix sys_perf_event_open() race against self

stable inclusion
from stable-v4.19.245
commit 6cdd53a49aa7413e53c14ece27d826f0b628b18a
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I593PQ


CVE: CVE-2022-1729

--------------------------------

commit 3ac6487e 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: f63a8daa ("perf: Fix event->ctx locking")
Reported-by: default avatarNorbert Slusarek <nslusarek@gmx.net>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarLi Huafei <lihuafei1@huawei.com>
Reviewed-by: default avatarYang Jihong <yangjihong1@huawei.com>
Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
parent 29d51b51
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment