Skip to content

Commit

Permalink
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/tip/tip

Pull perf fix from Ingo Molnar:
 "A single fix to not allow nonsensical event groups that result in
  kernel warnings"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/core: Fix group {cpu,task} validation
  • Loading branch information
torvalds committed Aug 26, 2017
2 parents b3242db + 64aee2a commit 53ede64
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -10032,28 +10032,27 @@ SYSCALL_DEFINE5(perf_event_open,
goto err_context;

/*
* Do not allow to attach to a group in a different
* task or CPU context:
* Make sure we're both events for the same CPU;
* grouping events for different CPUs is broken; since
* you can never concurrently schedule them anyhow.
*/
if (move_group) {
/*
* Make sure we're both on the same task, or both
* per-cpu events.
*/
if (group_leader->ctx->task != ctx->task)
goto err_context;
if (group_leader->cpu != event->cpu)
goto err_context;

/*
* Make sure we're both events for the same CPU;
* grouping events for different CPUs is broken; since
* you can never concurrently schedule them anyhow.
*/
if (group_leader->cpu != event->cpu)
goto err_context;
} else {
if (group_leader->ctx != ctx)
goto err_context;
}
/*
* Make sure we're both on the same task, or both
* per-CPU events.
*/
if (group_leader->ctx->task != ctx->task)
goto err_context;

/*
* Do not allow to attach to a group in a different task
* or CPU context. If we're moving SW events, we'll fix
* this up later, so allow that.
*/
if (!move_group && group_leader->ctx != ctx)
goto err_context;

/*
* Only a group leader can be exclusive or pinned
Expand Down

0 comments on commit 53ede64

Please sign in to comment.