Commit 3ac6487
perf: Fix sys_perf_event_open() race against self
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: f63a8da ("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>1 parent 3b5e159 commit 3ac6487
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12217 | 12217 | | |
12218 | 12218 | | |
12219 | 12219 | | |
| 12220 | + | |
| 12221 | + | |
| 12222 | + | |
12220 | 12223 | | |
12221 | 12224 | | |
12222 | 12225 | | |
| |||
12282 | 12285 | | |
12283 | 12286 | | |
12284 | 12287 | | |
| 12288 | + | |
12285 | 12289 | | |
12286 | 12290 | | |
12287 | 12291 | | |
| |||
12298 | 12302 | | |
12299 | 12303 | | |
12300 | 12304 | | |
| 12305 | + | |
| 12306 | + | |
| 12307 | + | |
| 12308 | + | |
| 12309 | + | |
| 12310 | + | |
| 12311 | + | |
| 12312 | + | |
| 12313 | + | |
12301 | 12314 | | |
| 12315 | + | |
12302 | 12316 | | |
12303 | 12317 | | |
12304 | 12318 | | |
| |||
0 commit comments